Bug 51041

Summary: A major problem with parsing formula
Product: POI Reporter: Carl <liyt0915>
Component: HSSFAssignee: POI Developers List <dev>
Severity: major    
Priority: P2    
Version: 3.6-dev   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Carl 2011-04-08 00:45:44 UTC
    I found a problem when i set a formula in a cell.
    I set some cell's value , and export it , like this.
    Cell A1 's value is int(1), cell B1's value is int(2), and a fomula in cell C1 is "=sum(A1+B1)".
   When i export this excel file, i find the formula can't calculate right. It shows "#VALUE!".

    Then i found something for this problem.
    In the last case, poi parsed the formula and the result of tokens was :
    1. RefPtg  ptgclass (Ptg.CLASS_REF)         A1
    2. RefPtg  ptgclass (Ptg.CLASS_REF)         B1
    3. AddPtg                                                 +
    4. FunVarPtg                                           SUM
    The excel show it can't work when doing the add action.
    And if i parsed the formula "=A1+B1", the result of tokens was :
    1. RefPtg  ptgclass (Ptg.CLASS_VALUE)    A1
    2. RefPtg  ptgclass (Ptg.CLASS_VALUE)    B1
    3. AddPtg                                                 +
    and it calculate right;

    so i guess maybe excel only can do add action when the two ptg's ptgclass is Ptg.CLASS_VALUE.

    Sorry for my poor english.
Comment 1 Nick Burch 2011-04-08 07:08:23 UTC
You are aware that you need to use the FormulaEvaluator to calculate the cached formula value? That needs to be done after changing any formulas, and before saving the file. Otherwise you'll get the behaviour you describe of #VALUE! in excel, until you trigger the recalculation

Can you confirm if you're doing a formula evaluation?
Comment 2 Dominik Stadler 2015-05-31 21:49:20 UTC
No response on the question in the previous comment, therefore closing this as WORKSFORME now. Please reopen the bug with more information if this is still a problem for you.