Diagnosing an Oledb Exception When Quering Excel 2010

Diagnosing an OLEDB exception when Quering Excel 2010

Perhaps you uninstalled the Access Database Engine (ACE) components? They are still available for download from MSDN as 2007 Office System Driver: Data Connectivity Components.

asp.net 4.0 to excel 2010 in command line app not working - drivers not found even after driver install

I did several things so I'm not sure if all the steps are important.

I registered my dlls according to this kb article http://support.microsoft.com/kb/209805. Before registering them, I verified there were no entries in the registry. This got me to the ISAM not found exception.

Then, thanks to Dave R, I changed my connection string. The final connection string that worked was (notice the escaped quotes on the Extended Properties)

string connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;data source={0};Extended Properties=\"Excel 12.0 Xml;IMEX=1\"", filename);

I didn't realize the file extension (.xlsx) was relavant to the connection string but after reading the connection string information here (http://www.connectionstrings.com/excel-2007), I fixed it.

Parsing excel files fails

Save yourself time and headache and use EPPLUS instead. EPPLUS can be installed via Nuget and you don't have to deal with installing the Office Data access on other machine where your code runs.



Related Topics



Leave a reply



Submit