Bug 29262

Summary: org.apache.poi.hssf.record.FormatRecord.field_1_index_code has value of -1.
Product: POI Reporter: Lonny Bastien <lonny>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED WORKSFORME    
Severity: critical    
Priority: P1    
Version: 2.5-FINAL   
Target Milestone: ---   
Hardware: All   
OS: Windows 2000   
URL: http://tonto.eia.doe.gov/oog/ftparea/wogirs/xls/psw14.xls

Description Lonny Bastien 2004-05-28 00:06:07 UTC
Description:
It appears that the field_1_index_code field in the 
org.apache.poi.hssf.record.FormatRecord class can attain a value of -1.
 
This causes the HSSFDataFormat to throw an ArrayIndexOutOfBoundsException on 
line 109 because the FormatRecord’s field_1_index_code field is used as an 
index into a Vector where all the FormatRecords for the workbook are stored. 

Steps to Reproduce:

Open the file: http://tonto.eia.doe.gov/oog/ftparea/wogirs/xls/psw14.xls and an 
ArrayIndexOutOfBoundsException is thrown on line 109 of HSSFDataFormat.

This error occurs for version 2.0 and 2.5

Notes:
The format record is read in and is stored to the Workbook on line 192 of the 
org.apache.poi.hssf.model.Workbook.java. 

BackGround:
After reading the OpenOffice document for FormatRecord, 
http://sc.openoffice.org/excelfileformat.pdf, it appears that -1 is an invalid 
index for a Format Record but I am not sure if the -1 is caused from HSSF 
incorrectly reading the Excel File or if the actual FormatRecord is stored with 
an index of -1.
Comment 1 Avik Sengupta 2005-05-20 13:40:58 UTC
Could you tell us how this file was created? 
Comment 2 Jason Height 2006-07-24 12:52:18 UTC
When i open that file URL in excel is already complains about DataFormats being
lost.

Sugest that whatever generated this file (probably an early version of POI who
knows!!!) was not generating a correct file structure.

When i resave in excel, no exception is raised (when calling
HSSFWorkbook.createDataFormat())

Jason