Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.E

一个C#应用程序在尝试将TXT数据导出到Excel时遇到错误,具体表现为InvalidCastException,原因是尝试将COM对象转换为'Microsoft.Office.Interop.Excel.Application'接口失败。错误代码E_NOINTERFACE表示不支持该接口。通过排查发现,问题源于Office安装不正确,重新安装Office后,问题得到解决。
摘要由CSDN通过智能技术生成

      前段时间做了个将Txt中数据导出到Excel中的C#小应用程序,一直都运行很好的。今天突然有同事安装时,报如下错:

************** Exception Text **************
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Excel.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: 不支持此接口 (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
   at TxtToExcelDemo.ExcelOperate.ExcelFileOperate.CreateExcelFile()
   at TxtToExcelDemo.MainForm.btnLoadOut_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Mess

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值