I am trying to use the XSSF POI to evaluate some Excel formulas. The values ββdo not need to be stored, and I may have to calculate many formulas, so I am trying to do all this in the same cell.
The problem is that the cell value seems to be stuck in the first formula introduced even after I recounted
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); XSSFCell formulaCell = row.createCell(6); formulaCell.setCellFormula("Date(2011,10,6)"); CellValue cellValue = evaluator.evaluate(formulaCell); System.out.println(cellValue.getNumberValue()); formulaCell.setCellFormula("Date(1911,3,4)"); cellValue = evaluator.evaluate(formulaCell); System.out.println(cellValue.getNumberValue());
Conclusion 40822.0 40822.0 (exceeds the equivalent of 10/6/2011) both times instead of reevaluating the new formula.
source share