虎泰克博客

无法将类型为“Microsoft.Office.Interop.Excel.ApplicationClass”的COM 对象强制转换为接口类型“Microsoft.Office.Interop.Exc


使用asp.net读取xls文件时报该错误,经过搜索得到解决方案顺利解决,经测试,该方法同样适用于W

使用asp.net读取xls文件时报该错误,经过搜索得到解决方案顺利解决,经测试,该方法同样适用于Word。

原文地址:http://www.cnblogs.com/sunxin88/articles/3456395.html

如果您使用的电脑要操作的是Office 2003而之前使用过Office 2007使用此方法可解决您的问题

无法将类型为“Microsoft.Office.Interop.Excel.ApplicationClass”的COM对象强制转换为接口类型“Microsoft.Office.Interop.Excel._Application”。此操作失败的原因是对 IID 为“{000208D5-0000-0000-C000-000000000046}”的接口的COM组件调用QueryInterface因以下错误而失败: 库没有注册。(异常来自HRESULT:0x8002801D (TYPE_E_LIBNOTREGISTERED))。英文版的异常消息如下:

Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' 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: could not be found. (Exception from HRESULT: 0x80030002 (STG_E_FILENOTFOUND)).

出现的原因可能是安装Office时安装过不同版本造成的

本人安装的是Office 2013,并安装过Office 2016,也安装过Office Access 2007

解决办法:

在注册表中找到:

HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}\1.6、1.9 删除之

就可以了。

因为我用的是Office 2013对应的是1.8,所以删除1.6、1.9

Office 2007对应的是1.6,Office 2016对应的是1.9,所以要根据情况判断。



Statement: all articles / drawings reproduced on this website are for the purpose of transmitting more information and facilitating discussion, which does not mean that the website, the host and the organizer agree with their opinions or confirm the authenticity of their contents. The contents of the articles are for reference only. If the rights of the original author are violated, please contact the website administrator.

Sign in to comment

Comment list

    No data