简体   繁体   中英

Saving an Excel Workbook on the Server through ASP.NET and IIS7

The following code samples produce the same error when I perform the SAVEAS:

Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
filePath = (string.Format("{0}.{1}", Path.GetTempFileName(), "xls"));

...do some stuff to the workbook ...

excelApp.DisplayAlerts = false;
excelApp.ActiveWorkbook.SaveAs(filePath)

OR

Missing m = Missing.Value;
excelApp.ActiveWorkbook.SaveAs(filePath, m, m,m,m,m, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, m,m,m);

OR

excelApp.ActiveWorkbook.SaveAs(filePath, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value);

Here's the error: Exception: System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC at Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs(Object Filename, Object FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local) at Common.CreateTempExcelFile(DataTable data)

I had the Office 2003 interops on the server but have upgraded to 2007. No difference.

Incidentally, I can write a text file to the same file/path so it's not a permissions error on the folder.

Thanks in advance,

Jim

看来已安装了无效的互操作版本的Excel。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM