Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

reading excel using HSSF, errors

807597Aug 20 2005 — edited Nov 20 2007
Hi all,
I've recently started exploring the usage of POI/HSSF to just do simple reading of excel .xls files. The code works fine on excel sheets that i have created on my own. But for some reason, i have tried this reader on a more complicated excel file, and it does not seem to be able to create the HSSFWorkBook from the POIFSFileSystem.

POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream (filename));
HSSFWorkbook hssfworkbook = new HSSFWorkbook(fs);

The following is the error msges displayed after running the program with the more complicated excel file.

--------------------------------------------------
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:224)
at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:160)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:130)
at ReadExcelExample.main(ReadExcelExample.java:24)
Caused by: java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.apache.poi.hssf.record.UnknownRecord.<init>(UnknownRecord.java:62)
at org.apache.poi.hssf.record.SubRecord.createSubRecord(SubRecord.java:57)
at org.apache.poi.hssf.record.ObjRecord.fillFields(ObjRecord.java:99)
at org.apache.poi.hssf.record.Record.fillFields(Record.java:90)
at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:61)
... 9 more
org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance, the following exception occured: null
at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:237)
at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:160)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:130)
at ReadExcelExample.main(ReadExcelExample.java:24)
-----------------------------------------------

If anyone could help me solve my problem it would be greatly appreciated. if there is anything else i can provide to help you answer my ques pls let me know.... thank you all for you time.

cheers
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 18 2007
Added on Aug 20 2005
12 comments
2,830 views