During my current project I had some work of reading and writing from an Excel file. I simply started with a Google Search
and found many solutions, but the one provided by David Hayden was excellent Read Here. Here I wont describe this article as its already really good, I will discuss the problem encountered in using this instead.
One major problem was to read the Excel spreadsheet at first place, David has used a connection string somewhat like:
string connectionString = @”Provider=Microsoft.Jet.
OLEDB.4.0;Data Source=Book1.xls;Extended
Properties=”"Excel 8.0;HDR=YES;”"”;
I was trying to read from an Office 2007 excel file and exceptions were encountered due to the above connection string. so I changed it to :
string connectionString = String.Format(@”Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=”"Excel 12.0;HDR=YES;”"”, this.FilePath);
where this.FilePath contains the full path of the excel file.
Changing the conn string worked like a charm and everything is working fine now.
Related articles by Zemanta
- HTML Table to Excel to CSV (ask.metafilter.com)
- Copy & pasting from Excel into Word (ask.metafilter.com)




