Bug 51378 - getDataFormatString crashes
Summary: getDataFormatString crashes
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.8-dev
Hardware: All All
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-15 14:27 UTC by jxz164
Modified: 2011-06-16 10:18 UTC (History)
0 users



Attachments
Java code and Excel files to reproduce the getDataFormatString crash (10.21 KB, application/zip)
2011-06-15 14:27 UTC, jxz164
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jxz164 2011-06-15 14:27:07 UTC
Created attachment 27159 [details]
Java code and Excel files to reproduce the getDataFormatString crash

The getDataFormatString method call crashes when reading the test file 

test-data\spreadsheet\12561-1.xls

with the following stack trace.

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 56
	at java.util.Vector.get(Vector.java:694)
	at org.apache.poi.hssf.usermodel.HSSFDataFormat.getFormat(HSSFDataFormat.java:146)
	at org.apache.poi.hssf.usermodel.HSSFCellStyle.getDataFormatString(HSSFCellStyle.java:133)
	at org.apache.poi.hssf.usermodel.HSSFCellStyle.getDataFormatString(HSSFCellStyle.java:110)
	at org.apache.poi.ss.examples.ReadDataFormat.getDataFormat(ReadDataFormat.java:15)
	at org.apache.poi.ss.examples.ReadDataFormat.main(ReadDataFormat.java:34)

This happens in both poi-3.8-beta3 and poi-3.7.

I tested another Excel file and found that it failed with similar stack trace in poi-3.8-beta3 but succeeded in poi-3.7. I believe there is a regression here.

Please see attached source code and two Excel files to reproduce this issue.
Comment 1 Nick Burch 2011-06-15 14:39:21 UTC
Your style is claiming to be format 56, but POI can't find a format with that ID

If you open the file in excel, and do a "save as", does that fix your problem?

What does OpenOffice make of the file?

How was your excel file generated?
Comment 2 jxz164 2011-06-15 14:57:22 UTC
The attachment contains two files. The file 12561-1.xls is from shipped poi-3.8-beta3 under the test-data directory. Both POI-3.8-beta3 and POI 3.7 have trouble reading it. Yes, if I save it in Excel again, it will read OK. I don't have openoffice to test it.

The second file O_27272_2.xls was created by POI and resave it in Excel does not help. The crash happens only in POI-3.8-beta3, but not POI 3.7.
Comment 3 Yegor Kozlov 2011-06-16 10:18:06 UTC
Should be fixed in r1136352

Yegor