我正在尝试从我的 ASP.NET 应用程序访问 Excel 宏。当我尝试在 Visual Studio 中本地运行它时,它工作得很好,但是一旦我将它部署到我的 IIS 网络服务器上,我就会收到以下错误:
我正在使用 Interop.Microsoft.Office.Interop.Excel.dll 类来访问 Excel 文件并像这样运行宏:
// Create an instance of Microsoft Excel, make it visible, and open AquaticChemistry
Excel.ApplicationClass oExcel = new Excel.ApplicationClass();
oExcel.Visible = true;
Excel.Workbooks oBooks = oExcel.Workbooks;
Excel._Workbook oBook = null;
String excelFile = Server.MapPath("AquaticChemistry_DrinkingWater.xlsm");
oBook = oBooks.Open(excelFile, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
// Run the macro Phreeqc
RunMacro(oExcel, new Object[] { "RunPhreeqc", Server.MapPath("phreeqc_wt.dat") });
// Save and quit Excel and clean up
oBook.Save();
oBook.Close(false, oMissing, oMissing);
我试图让网络服务帐户访问 Excel 文件,但没有帮助。有什么建议么?