tags:

views:

36

answers:

2

Hi Guys,

Im trying to extract rows from excel using Oledb. For some excel files from certain people is throwing error while trying to open the connection. The error says "External table is not in the expected format."

Here is my connection string

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.xls;Extended Properties="Excel 8.0;HDR=NO;IMEX=1"

One important thing which I noted is, everything works fine if I kept the file open. Since the files are received from third party vendors, so there is no option to do a 'Save As'.

Thanks in advance! Manoj

A: 

Try to use the following connection string:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\test.xls;Extended Properties=Extended Properties=Excel 12.0;

External table is not in the expected format." typically occurs when trying to use an Excel 2007 file with a connection string that uses: Microsoft.Jet.OLEDB.4.0 and Extended Properties=Excel 8.0

MrZoidberg
Thanks! I had already tried this, but I was getting the same error. Also the file extension is .xls not .xlsx. Even I tried to import this file using Microsoft Query Wizard and ODBC (available in excel 2007), was getting the same error
Where were your test.xls created?
MrZoidberg
A: 

It is possible to stick an xls extension on several formats and have Excel open the file with little complaint. Try opening it in a text editor and checking whether or not it is a simple .csv, for example. This would explain why your connection string would work when the file was open.

Remou