当我添加跟随。代码,但在服务器上显示错误。代码 -
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 中未安装。任何人都可以在不安装任何服务器的情况下解决此问题。