Abhij
Abhij

Reputation: 1272

Microsoft ODBC Excel Driver

I am using ms excell as database in java program.
but i am getting following error.

java.sql.SQLException: [Microsoft][ODBC Excel Driver] External table is not in the expected format

I am not getting why this exception occurs.

Upvotes: 0

Views: 8477

Answers (1)

Łukasz Rżanek
Łukasz Rżanek

Reputation: 5836

Oh, that's the one I got quite often. It's one of many reasons why I'm switching to Apache POI

Here is the approach I got from our internal Wiki. Maybe it will help:

Approach one

Make sure you are using the correct ODBC driver for the version of excel (i.e. Excel 2003 or Excel 2007) you are trying to open. NOTE: The error in this instance "SQLDriverConnect failed :[Microsoft][ODBC Excel Driver] External table is not in the expected format.", was caused by selecting an Excel 2003 ODBC Driver to open up an Excel 2007 file.

To Configure an ODBC Excel Driver do the following:

  1. Open the Control Panel -> Administrative Tools -> Data Sources (ODBC)
  2. A Windows Dialog Box named "ODBC Data Source Administrator" will appear
  3. Click on the User DSN tab, then click Add
  4. Scroll down until you see "Microsoft Excel Driver (*.xls, *xlsx, *xlsm, *xlsb)", Select it, Click "Finish"
  5. A Windows Dialog Box named "ODBC Microsoft Excel Setup" will appear
  6. In the box next to "Data Source Name:" type in a name for the Data Source, i.e. "Excel 2007"
  7. In the box next to "Description:" type in a description. i.e. Excel 2007 ODBC Driver"
  8. In the drop down box next to "Database Version:" verify that "Excel 12.0" is selected for Excel 2007 (.xlsx) files, or "Excel 97-2000" is selected for Excel 2003 (.xls) files, etc.
  9. Click "OK" on the Windows Dialog Box named "ODBC Microsoft Excel Setup"
  10. Click "OK" on the Windows Dialog Box named "ODBC Data Source Administrator"

An Alternative Process

Instead of trying to reconfigure your ODBC settings, you can also open the Excel file directly in Statistics.

To open up your Excel file directly in Statistics, launch Statistics and do the following from the menus in the Statistics Data Editor Window:

  1. File>>Open>>Data and select "Excel(*.xls, *.xlsx, .xlsm)" in the 'Files of type' dropdown menu NOTE: if you have Excel 2003 installed your value in the "Files of Type" dropdown menu will be "Excel(.xls)"
  2. Browse your system and select the Excel file you wish to open

If you can provide more information about what are you doing and how, maybe then I can give you some more detailed information.

Upvotes: 1

Related Questions