Bug 64341

Summary: Incorrect value returned for FormulaError on evaluating formula cell
Product: POI Reporter: Nishant Middha <MIDDHA.NISHANT173>
Component: XSSFAssignee: POI Developers List <dev>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: Spreadsheet for above test case.

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.