You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Chris Barlock <ba...@us.ibm.com> on 2006/12/21 02:56:38 UTC

Exception Reading XLS File

I found an XLS file that throws an Exception when read:

D:\temp4>java -classpath 
.;D:\eclipsews\gatepost\poke-post\tools\poi-2.5.1-final-20040804.jar Test 
D:\eclipsews\gatepost\poke-post\tools\PokTCG.xls
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
Method)
        at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)
        at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java(Compiled 
Code))
        at 
java.lang.reflect.Constructor.newInstance(Constructor.java(Compiled Code))
        at 
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java(Compiled 
Code))
        at 
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java(Compiled 
Code))
        at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
        at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:130)
        at Test.main(Test.java:12)
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(Compiled Code))
        at org.apache.poi.hssf.record.Record.<init>(Record.java(Compiled 
Code))
        at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:61)
        ... 9 more
Exception in thread "main" 
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(Compiled 
Code))
        at 
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java(Compiled 
Code))
        at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
        at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:130)
        at Test.main(Test.java:12)

The source for Test.java which demonstrates this failure is:

import java.io.FileInputStream;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

public class Test {
    public static void main(String[] args) throws Exception {
        String filename = args[0];

        FileInputStream fis = new FileInputStream(filename);
        POIFSFileSystem fs = new POIFSFileSystem(fis);
        HSSFWorkbook hssfwb = new HSSFWorkbook(fs);
    }
}

Since I'm not sure how well attachments make it through this mailing list, 
the XLS file is the only content of:

http://www.pokepedia.net/pokTCG.zip

I can export this file in CSV format and use other tools to read it, but 
it sure would be nice to read the XLS directly!

Chris

Internet:  barlock@us.ibm.com