Reading Excel Files In C# Always Results In System.__ComObject?
Posted
by
Soo
on Stack Overflow
See other posts from Stack Overflow
or by Soo
Published on 2011-01-07T16:38:07Z
Indexed on
2011/01/07
16:54 UTC
Read the original article
Hit count: 232
This is the code I'm using to read an xls file:
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(filePath, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
Microsoft.Office.Interop.Excel.Sheets excelSheets = excelWorkbook.Worksheets;
Microsoft.Office.Interop.Excel.Worksheet excelSheet = (Microsoft.Office.Interop.Excel.Worksheet)excelSheets.get_Item(1);
MessageBox.Show(excelSheet.Cells[1,1].ToString());
Which results in a message box with:
System.__ComObject
Not sure what's going on, I'd really appreciate any help, thanks!
© Stack Overflow or respective owner