Hi,
I have an Excel Sheet Which is Generated Using an Application Developed in OLD Foxpro Windows Based.
I am able to read this file using Excel 2K3 and 2K7...
The Entire Excel Sheet Contains Numerical Data, but its cell format tells it is "general"
Now I want to read this file and Perform a Simple Search Query. The Excel File contains only two Columns but around 8000+ records.
imp : I Dont wanna do any Manual steps in Excel. I should be able to do everything in java. The Excel File is Generated everyday, and the records keep on Changing, but not its Structure. i.e. this excel sheet is Temporary created.
I think the Foxpro generated an Excel97 format file, which is not supported now by d present drivers... This is what I Think, I am not sure on this statement.
Now what I tried to do is
1.
Tried to read Excel Sheet Using JDBC ODBC Driver from Microsoft. But Its was not Successful. The Connection Could Not be Created. It Shows me the following error.
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Excel Driver] External table is
not in the expected format.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3073)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at Query.Main.main(Main.java:12)
Java Result: 1
2.
Tried to read it using Apache POI API, but again no Success
It gives me the following error
java.io.IOException: Invalid header signature; read 4503608217567241, expected -2226271756974174256
at org.apache.poi.poifs.storage.HeaderBlockReader.<init>(HeaderBlockReader.java:112)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:151)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:312)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:293)
at Query.ExcelReadExample.main(ExcelReadExample.java:47)
After getting both these errors, I manually Opened my ExcelSheet and then Saved it by another name, n saying it to save it as Excel 97-2000 file. After doing this, the size of the Excel sheet increased. but now I dont have ney Exception when using JDBC ODBC.
please suggest me something, to work with this excel sheet, without changing it even a bit.
Thanking You,
Rinav G.