Bug 14460 - Name in Formula - ArrayOutOfBoundsException
Summary: Name in Formula - ArrayOutOfBoundsException
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.0-dev
Hardware: Other other
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-12 00:19 UTC by Dennis Doubleday
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
Minimal XLS file that demonstrates the problem (18.00 KB, application/octet-stream)
2002-11-12 00:20 UTC, Dennis Doubleday
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Doubleday 2002-11-12 00:19:38 UTC
The attached spreadsheet has just one formula. It looks like this:

D3+PriceDown

where PriceDown is a Name. You get the following exception when using 
BiffViewer:

java.lang.ArrayIndexOutOfBoundsException
        at org.apache.poi.util.LittleEndian.getNumber(LittleEndian.java:557)
        at org.apache.poi.util.LittleEndian.getShort(LittleEndian.java:90)
        at org.apache.poi.hssf.record.formula.NamePtg.<init>(NamePtg.java:100)
        at org.apache.poi.hssf.record.formula.Ptg.createPtg(Ptg.java:251)
        at org.apache.poi.hssf.record.FormulaRecord.getParsedExpressionTokens(Fo
rmulaRecord.java:171)
        at org.apache.poi.hssf.record.FormulaRecord.fillFields(FormulaRecord.jav
a:147)
        at org.apache.poi.hssf.record.Record.fillFields(Record.java:143)
        at org.apache.poi.hssf.record.Record.<init>(Record.java:105)
        at org.apache.poi.hssf.record.FormulaRecord.<init>(FormulaRecord.java:11
8)
        at org.apache.poi.hssf.dev.BiffViewer.createRecord(BiffViewer.java:550)
        at org.apache.poi.hssf.dev.BiffViewer.createRecords(BiffViewer.java:158)

        at org.apache.poi.hssf.dev.BiffViewer.run(BiffViewer.java:110)
        at org.apache.poi.hssf.dev.BiffViewer.main(BiffViewer.java:687)

It seems to happen only when you mix non-named cell references with named ones. 
For example, I tried formulae like C1+D1 and Name1:Name2 and they both parsed.
Comment 1 Dennis Doubleday 2002-11-12 00:20:31 UTC
Created attachment 3814 [details]
Minimal XLS file that demonstrates the problem
Comment 2 Avik Sengupta 2003-10-06 17:33:17 UTC
This is fixed in latest CVS, and also possibly in 2.0pre3. Added the xls file as
a testcase. (HEAD tho is hosed!)