当我添加foll时代码但在服务器上显示错误。 代码 -
object oMissing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Excel.ApplicationClass xl = new Microsoft.Office.Interop.Excel.ApplicationClass();
Microsoft.Office.Interop.Excel.Workbook xlBook;
Microsoft.Office.Interop.Excel.Worksheet xlSheet;
xlBook = (Workbook)xl.Workbooks.Open(docPath, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
xlSheet = (Worksheet)xlBook.Worksheets.get_Item(1);
xlSheet.Name = "Sheet1";
xlBook.Save();
xl.Application.Workbooks.Close();
错误 -
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
我在webApplication中添加了“Microsoft.Office.Interop.Excel”dll的引用。 在当地它的工作正常。 注意:在服务器中,未安装Microsoft Office。 任何人都可以在服务器上没有任何安装的情况下解决这个问题。