gpt4 book ai didi

C# System.Runtime.InteropServices.COMException (0x800A03EC) : Exception from HRESULT: 0x800A03EC Microsoft. Office.Interop.Excel._Workbook.SaveAs()

转载 作者:行者123 更新时间:2023-12-03 11:09:41 40 4
gpt4 key购买 nike

在 Windows 服务器 2008 和 2012 上运行时,我在保存 Excel 电子表格时遇到问题,但这个项目在本地电脑上运行(Windows 7,8 或 10)

C#源代码

Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook excelWorkBook = excelApp.Workbooks.Add();
Microsoft.Office.Interop.Excel.Worksheet excelWorkSheet = excelWorkBook.Worksheets.Add();
excelWorkSheet.Name = "blablabla";
//added cells data
excelWorkBook.SaveAs(excelPath.ToString());
excelWorkBook.Close();
excelApp.Quit();

错误信息

Exception from HRESULT: 0x800A03EC System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC at Microsoft.Office.Interop.Excel._Workbook.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)

最佳答案

在服务器中安装 MS Office 以在您的项目中运行 office.interop 程序集是最佳选择。

同样,如果您根本不想在服务器机器上安装 MS Office,那么您可以安装 PIA(主互操作程序集)

http://msdn.microsoft.com/en-us/library/kh3965hw.aspx

PIA for office 下载链接

http://www.microsoft.com/downloads/details.aspx?FamilyID=59daebaa-bed4-4282-a28c-b864d8bfa513&DisplayLang=en

关于C# System.Runtime.InteropServices.COMException (0x800A03EC) : Exception from HRESULT: 0x800A03EC Microsoft. Office.Interop.Excel._Workbook.SaveAs(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46075307/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com