试图获得工作表的引用(使用Excel interop):
Excel.Application xl = new Excel.ApplicationClass(); Excel.Workbooks xlWorkBooks = xl.Workbooks; Excel.Workbook xlWorkBook = xlWorkBooks.Open(fileName,false,5,"",true,Excel.XlPlatform.xlWindows,"\t",1,0); // Next line crashes Excel.Worksheets xlWorkSheets = (Excel.Worksheets) xlWorkBook.Worksheets;
错误是它不能转换它:
Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘Microsoft.Office.Interop.Excel.Worksheets’. This operation Failed because the QueryInterface call on the COM component for the interface with IID ‘{000208B1-0000-0000-C000-000000000046}’ Failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
我的演员是不正确的吗?