Bug 44306 - Support getCellFormula() for CHOOSE formulas without triggering EmptyStackException
Summary: Support getCellFormula() for CHOOSE formulas without triggering EmptyStackExc...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-28 04:15 UTC by Nick Burch
Modified: 2008-05-18 18:46 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Burch 2008-01-28 04:15:42 UTC
On a formula
    =CHOOSE(2,A2,A3,A4)

calling cell.getCellFormula() will blow up with an EmptyStackException

Not sure if it's a bug with the formula parser, or the processing of the Ptgs

Test for the Ptg parsing is in
src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java#testWithConcat()
but may not be fully correct

Test for the usermodel side is in
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java#test42618() with the
last line calling getCellFormula commented out
Comment 1 Josh Micich 2008-05-18 18:46:26 UTC
Fixed in svn r657702.

There were two problems: tAttrChoose was ignoring the following jump-table and FormulaParser.toFormulaString() needed to handle the extra case of tAttrChoose.

By not reading the extra data belonging to the choose AttrPtg, POI would interpret that data as subsequent Ptgs which had unpredictable results (none good).


Note - as of this fix POI is still not able to evaluate formulas involving CHOOSE() (see bug 45031)