Last post Aug 21, 2010 03:04 PM by notulei
Aug 21, 2010 11:03 AM|notulei|LINK
I have a web app where user uploads a file.
File is saved in server locally and I want to read some data from it.
Currently my development server has office 2003.
So do I need office 2007 in order to be able to read an excel from office 2007 ?
What are other requirements ?
I tried a test, using
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook wrkBook; // = new Microsoft.Office.Interop.Excel.Workbook();
wrkBook = excelApp.Workbooks.Open(@"C:\www\excel_files\b.xls", ....);
But When trying to open the file I get the error:
Exception from HRESULT: 0x800A03EC
So I'm wondering what I'm missing.
c# excel COM Interop
Aug 21, 2010 01:08 PM|sansan|LINK
check this article.
Aug 21, 2010 01:12 PM|tanatrajan|LINK
This code should help you. Here I am binding to a DataGrid.
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\inetpub\\wwwroot\\lotto.xls;Extended Properties=Excel 8.0;";
string MySQL = "Select * from [lotto$]";
System.Data.OleDb.OleDbConnection Conn = new System.Data.OleDb.OleDbConnection(strConn);
System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(MySQL, Conn);
DataSet ds = new DataSet();
MyDataGrid.Datasource = ds.Tables.DefaultView;
Aug 21, 2010 03:04 PM|notulei|LINK
Thanks for your reply. I had read that article before.
But, it's a bit different from what I need since the example in the article uses an excel file that is like a db table. However I need to access specific rows and columns and that's why I'm trying to use COM Interop and not ADO.