gpt4 book ai didi

c# - Excel.Application 异常

转载 作者:行者123 更新时间:2023-12-04 20:28:09 28 4
gpt4 key购买 nike

在应用程序的主要部分,我称之为这一行:

Excel.Application ExcelApp = new Excel.Application();

它给了我一个异常(exception):
System.Runtime.InteropServices.COMException: 'Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).'

我尝试在 x86 中运行调试,x64 模式是相同的结果。

enter image description here

最佳答案

尝试像这样声明它们,完全合格:

Microsoft.Office.Interop.Excel.Application xlapp = new Microsoft.Office.Interop.Excel.Application();

                 Microsoft.Office.Interop.Excel.Application xlApp;
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;

关于c# - Excel.Application 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55502420/

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