问题描述
使用Power Pivot导出文件时报错,错误提示为:
System.InvalidCastException: 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: 库未注册。 (Exception from HRESULT: 0x8002801D (TYPE_E_CANTLOADLIBRARY)).
报错截图如下:
解决方法
这个问题是由于之前安装过WPS,没有卸载干净,WPS恶意更改了office的Com组件注册权限,使得office的com组件不能注册,所以WPS和office尽量不要一起用。