Bug 26100 - 128-character message in IF statement cell causes HSSFWorkbook open failure
Summary: 128-character message in IF statement cell causes HSSFWorkbook open failure
Status: RESOLVED FIXED
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
URL:
Keywords:
: 26894 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-01-13 15:31 UTC by Jun Zuo
Modified: 2007-01-16 01:34 UTC (History)
1 user (show)



Attachments
Sample Excel file (version Excel 2000) (21.00 KB, application/excel)
2004-01-13 16:11 UTC, Jun Zuo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jun Zuo 2004-01-13 15:31:48 UTC
In version 2.0 (2.0-RC2) but not 1.5.1, if a cell contains an IF statement that 
has a message longer than 127 characters, the following error occurs:

java.lang.reflect.InvocationTargetException: 
java.lang.IllegalArgumentException: Illegal length
	at org.apache.poi.util.StringUtil.getFromUnicode(StringUtil.java:170)
	at org.apache.poi.hssf.record.formula.StringPtg.<init>
(StringPtg.java:92)
	at org.apache.poi.hssf.record.formula.Ptg.createPtg(Ptg.java:272)
	at org.apache.poi.hssf.record.FormulaRecord.getParsedExpressionTokens
(FormulaRecord.java:181)
	at org.apache.poi.hssf.record.FormulaRecord.fillFields
(FormulaRecord.java:157)
	at org.apache.poi.hssf.record.Record.fillFields(Record.java:127)
	at org.apache.poi.hssf.record.Record.<init>(Record.java:92)
	at org.apache.poi.hssf.record.FormulaRecord.<init>
(FormulaRecord.java:122)
	at java.lang.reflect.Constructor.newInstance(Native Method)
	at org.apache.poi.hssf.record.RecordFactory.createRecord
(RecordFactory.java:257)
	at org.apache.poi.hssf.record.RecordFactory.createRecords
(RecordFactory.java:193)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:207)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:254)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:235)
Comment 1 Avik Sengupta 2004-01-13 15:38:43 UTC
I vaguely remember there was a good reason for this limitation in POI .. I
thought excel had issues with long strings in formulas in some situations.. You
are trying to read an existing excel file, i presume??

Is it possible for you to attach the file to this bug? What version of Excel did
u save the file with?
Comment 2 Jun Zuo 2004-01-13 16:11:29 UTC
Created attachment 9937 [details]
Sample Excel file (version Excel 2000)
Comment 3 Jun Zuo 2004-01-13 16:13:15 UTC
With the attached Excel, the error is:

java.lang.reflect.InvocationTargetException: 
java.lang.StringIndexOutOfBoundsException: length must be >= 0
	at java.lang.String.<init>(Unknown Source)
	at java.lang.String.<init>(Unknown Source)
	at org.apache.poi.util.StringUtil.getFromCompressedUnicode
(StringUtil.java:212)
	at org.apache.poi.hssf.record.formula.StringPtg.<init>
(StringPtg.java:94)
	at org.apache.poi.hssf.record.formula.Ptg.createPtg(Ptg.java:272)
	at org.apache.poi.hssf.record.FormulaRecord.getParsedExpressionTokens
(FormulaRecord.java:181)
	at org.apache.poi.hssf.record.FormulaRecord.fillFields
(FormulaRecord.java:157)
	at org.apache.poi.hssf.record.Record.fillFields(Record.java:127)
	at org.apache.poi.hssf.record.Record.<init>(Record.java:92)
	at org.apache.poi.hssf.record.FormulaRecord.<init>
(FormulaRecord.java:122)
	at java.lang.reflect.Constructor.newInstance(Native Method)
	at org.apache.poi.hssf.record.RecordFactory.createRecord
(RecordFactory.java:257)
	at org.apache.poi.hssf.record.RecordFactory.createRecords
(RecordFactory.java:193)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:207)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:254)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:235)
	
Comment 4 Avik Sengupta 2005-05-20 12:11:36 UTC
*** Bug 26894 has been marked as a duplicate of this bug. ***
Comment 5 Avik Sengupta 2007-01-16 01:34:03 UTC
Works as of 12Jan2007, Testcase added. 
http://issues.apache.org/bugzilla/show_bug.cgi?id=41366