通过 ASP.NET 和 IIS7 在服务器上保存 Excel 工作簿
当我执行 SAVEAS 时,以下代码示例会产生相同的错误:
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
filePath = (string.Format("{0}.{1}", Path.GetTempFileName(), "xls"));
...对工作簿执行一些操作 ...
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);
这是错误: 异常:System.Runtime.InteropServices.COMException (0x800A03EC):来自 HRESULT 的异常:0x800A03EC 在 Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs(对象文件名、对象文件格式、对象密码、对象 WriteResPassword、对象 ReadOnlyRecommended、对象 CreateBackup、XlSaveAsAccessMode AccessMode、对象冲突解决方案、对象 AddToMru、对象 TextCodepage、对象 TextVisualLayout、对象本地) 在 Common.CreateTempExcelFile(DataTable data)
我在服务器上有 Office 2003 互操作,但已升级到 2007。没有区别。
顺便说一句,我可以将文本文件写入同一文件/路径,因此这不是文件夹上的权限错误。
提前致谢,
吉姆
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来安装了无效的 Excel 互操作版本。
Looks like invalid interop version of Excel was installed.