There is a code
private void buttonAct_Click(object sender, EventArgs e) { try { _excelApp = new Excel.Application(); _wkb = _excelApp.Workbooks.Open(fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); Excel.Worksheet worksheet = (Excel.Worksheet)_wkb.Worksheets[1]; Excel.Range excelRange = worksheet.UsedRange; object[,] valueArray = (object[,])excelRange.get_Value( Excel.XlRangeValueDataType.xlRangeValueDefault); //access the cells for (int row = 1; row <= worksheet.UsedRange.Rows.Count; ++row) { articul = valueArray[row, 1].ToString(); } } catch (Exception ex) { throw ex; } finally { //clean up stuffs _wkb.Close(false, Type.Missing, Type.Missing); Marshal.ReleaseComObject(_wkb); _excelApp.Quit(); Marshal.FinalReleaseComObject(_excelApp); } } When opening an Excel workbook, such an error occurs.
It is not possible to cast a COM object of type "Microsoft.Office.Interop.Excel.ApplicationClass" to the interface type "Microsoft.Office.Interop.Excel._Application". The operation failed because the QueryInterface COM component call for the interface with IID "{000208D5-0000-0000-C000-00000000004646}" returned the following error: Error loading library. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
Please help. thank