Bug 12136

Summary: NullPointerException when reading a large excel file
Product: POI Reporter: Elvira Gurevich <elvira_gurevich>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: blocker    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: excel file producing an error

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!):
java.lang.NullPointerException
        at org.apache.poi.hssf.usermodel.HSSFSheet.setPropertiesFromSheet(HSSFSh
eet.java:174)
        at org.apache.poi.hssf.usermodel.HSSFSheet.<init>(HSSFSheet.java:136)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:1
64)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:1
90)
        at com.ibi.preparsers.XDExcelpreParser.transform(XDExcelpreParser.java:1
07)
        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
(input.getBytes()));
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/

Jason
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!