开发者

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 200开发者_如何转开发7. 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


Looks like invalid interop version of Excel was installed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜