Bug 12136 - NullPointerException when reading a large excel file
Summary: NullPointerException when reading a large excel file
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P3 blocker (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2002-08-28 19:46 UTC by Elvira Gurevich
Modified: 2005-03-20 17:06 UTC (History)
0 users

excel file producing an error (21.50 KB, application/octet-stream)
2002-08-29 17:38 UTC, Elvira Gurevich

Note You need to log in before you can comment on or make changes to this bug.
Description Elvira Gurevich 2002-08-28 19:46:21 UTC
Running code from jakarta-poi-1.7.0-dev-bin.zip,
I get the following stack trace when reading a file of about 130 rows and 4 
columns( not really that big!):
        at org.apache.poi.hssf.usermodel.HSSFSheet.setPropertiesFromSheet(HSSFSh
        at org.apache.poi.hssf.usermodel.HSSFSheet.<init>(HSSFSheet.java:136)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:1
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:1
        at com.ibi.preparsers.XDExcelpreParser.transform(XDExcelpreParser.java:1
        at com.ibi.edaqm.XDWorker.parseAndValidate(XDWorker.java:1202)
        at com.ibi.edaqm.XDWorker.parseAndValidate(XDWorker.java:1147)
        at com.ibi.edaqm.XDFileWorker.run(XDFileWorker.java:208)
        at java.lang.Thread.run(Thread.java:484)

This does not happen when the file has 1 row less.
The call to HSSFWorkbook is as following:
        HSSFWorkbook workbook = new HSSFWorkbook(new ByteArrayInputStream
where the file was initially read into a String input.
Comment 1 Elvira Gurevich 2002-08-29 17:38:27 UTC
Created attachment 2870 [details]
excel file producing an error
Comment 2 Jason Height 2002-08-30 04:17:16 UTC
I ran the latest CVS against the attachment and the following worked fine:

HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream("c:/att.xls"));

Maybe the input.getBytes that you are calling is not providing the entire set 
of bytes or try the latest build from the nightly area and let us know if it is 
fixed or not: http://jakarta.apache.org/builds/jakarta-poi/nightly/

Comment 3 Elvira Gurevich 2002-08-30 14:36:57 UTC
you are right! we were reading the file as bytes, converting them to String and 
then converting back to bytes - sort of legacy design, since originally we were 
only dealing with character files. changing code to deal with the original byte 
array fixed this problem. Thanks!