我正在编写一个与excel文件一起使用的应用程序.我需要一个删除工作表的功能.我必须使用程序集Microsoft.Office.Interop.Excel.dll.
它在开发人员计算机上运行良好,但当我尝试在服务器上部署它时,我收到一个错误:
无法加载文件或程序集'office,Version = 14.0.0.0,Culture = neutral,PublicKeyToken = 71e9bce111e9429c'或其中一个依赖项
我知道在计算机上未安装MS Office时会出现问题.客户不希望以任何价格在服务器上安装和购买MS Office.
我按照此处的建议在开发人员计算机上安装"Redistributable Primary Interop Assemblies":http://forums.asp.net/t/1530230.aspx/1 并再次编译我的项目.
代码示例:
public bool DeleteSheet(string tableName)
{
Excel.Application app = null;
Excel.Workbooks wbks = null;
Excel._Workbook _wbk = null;
Excel.Sheets shs = null;
bool found = false;
try
{
app = new Excel.Application();
app.Visible = false;
app.DisplayAlerts = false;
app.AlertBeforeOverwriting = false;
wbks = app.Workbooks;
_wbk = wbks.Add(xlsfile);
shs = _wbk.Sheets;
int nSheets = shs.Count;
for (int i = 1; i …Run Code Online (Sandbox Code Playgroud) 现在当我查询
SELECT @@language
Run Code Online (Sandbox Code Playgroud)
它得到'us_english'.但我需要俄语.
我不能SET LANGUAGE russian用于每个查询.
我需要默认设置它(对于所有新会话).
我需要做这样的事情:http: //social.msdn.microsoft.com/Forums/en-US/wpf/thread/982e2fcf-780f-4f1c-9730-cedcd4e24320/
我决定按照约翰史密斯建议的最佳方式.
我试图在xaml中设置绑定,它不起作用(目标始终为null).
我决定在代码中手动设置绑定(用于调试目的),因此我需要执行DateRange对象的"SetBinding"方法.
DateRange类型的对象中不存在此方法.
有任何想法吗?
<TextBox Grid.Row="1"
Grid.Column="1"
Name="Xml_Name"
>
<TextBox.Text>
<Binding XPath="@name" UpdateSourceTrigger="PropertyChanged" >
<Binding.ValidationRules>
<local:UniqueValidationRule x:Name="uniqueDatasourcesRule001" >
<local:UniqueValidationRule.UniqueCollection>
<local:UniqueDependencyObject uu="{Binding ElementName=Xml_Name, Path=Name, UpdateSourceTrigger=PropertyChanged}" />
</local:UniqueValidationRule.UniqueCollection>
</local:UniqueValidationRule>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
public class UniqueDependencyObject : DependencyObject
{
public static readonly DependencyProperty uu11Property =
DependencyProperty.Register("uu", typeof(string), typeof(UniqueDependencyObject));
public string uu
{
set {
SetValue(uu11Property, value); }
get {
return (string)GetValue(uu11Property); }
}
}
public class UniqueValidationRule : ValidationRule
{
public UniqueDependencyObject UniqueCollection
{
get;
set;
} …Run Code Online (Sandbox Code Playgroud)