Bug 64341 - Incorrect value returned for FormulaError on evaluating formula cell
Summary: Incorrect value returned for FormulaError on evaluating formula cell
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-11 10:37 UTC by Nishant Middha
Modified: 2020-07-14 03:11 UTC (History)
0 users



Attachments
Spreadsheet for above test case. (4.28 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2020-04-11 10:37 UTC, Nishant Middha
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nishant Middha 2020-04-11 10:37:44 UTC
Created attachment 37169 [details]
Spreadsheet for above test case.

1. I am using below attached excel file.
2. In below excel cell A1 contains formula "=G2-G5" which evaluates to zero.
3. On evaluating this cell using FormulaEvaluator, value for formula error must be FormulaError._NO_ERROR but it is FormulaError.NULL
5. Apache POI version used is 3.17
4. Below mentioned is my code : 

// Java Code
try {
      // cell is instance of Cell A1 
      CellValue cellValue = formulaEvaluator.evaluate(cell);
      formulaError = FormulaError.forInt(cellValue.getErrorValue());
      System.out.println(formulaError);
      System.out.println(cell.getCachedFormulaResultTypeEnum()); 
    } catch (NotImplementedException ex) {
      
    } catch (FormulaParseException ex) {
      
    }

5. The output of the above-mentioned code is 
   NULL
   NUMERIC
6. There is an ambiguity here result type is NUMERIC and formula error is FormulaError.NULL but it should be FormulaError._NO_ERROR as formula successfully evaluates to zero.
Comment 1 chenlin 2020-07-14 03:11:17 UTC
Can you provide a complete test case? The code provided so far is so simple that I can't even recreate what you're trying to express. 
I try to write test cases based on this part of the code and file you provide, but I never get what I expect.