简体   繁体   English

通过ASP.NET和IIS7在服务器上保存Excel工作簿

[英]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: 当我执行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) 这是错误:异常: System.Runtime.InteropServices.COMException(0x800A03EC):来自HRESULT的异常:Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs处的0x800A03EC(对象文件名,对象FileFormat,对象密码,对象WriteResPassword,对象ReadOnlyRecommended,在Common.CreateTempExcelFile(DataTable data)处的对象CreateBackup,XlSaveAsAccessMode AccessMode,对象冲突解决方案,对象AddToMru,对象TextCodepage,对象TextVisualLayout,对象本地)

I had the Office 2003 interops on the server but have upgraded to 2007. No difference. 我在服务器上安装了Office 2003互操作性,但已升级到2007。没有区别。

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。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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