Greg,
Here is my code snippet and its output:
sheet.getRow(2).getCell(5).setCellValue(examDate); //
04/10/2019
sheet.getRow(2).getCell(7).setCellValue(birthDate);
// 01/01/1980
// output computed AGE value from cell B5 - Expected result: 39
FormulaEvaluator evaluator =
wb.getCreationHelper().createFormulaEvaluator();
Cell c = sheet.getRow(4).getCell(1);
CellValue cellValue = evaluator.evaluate(c);
evaluator.evaluate(c);
System.out.println("Cell Value (String) : "+
cellValue.toString());
System.out.println("Cell Value (Number) : "+
cellValue.getNumberValue());
System.out.println("Formula : " + c.getCellFormula());
System.out.println("CachedFormulaResultType : " +
c.getCachedFormulaResultType());
System.out.println("Numeric value : " +
c.getNumericCellValue());
And the output is :
Cell Value (String) : org.apache.poi.ss.usermodel.CellValue [#VALUE!]
Cell Value (Number) : 0.0
Formula : 'Unformatted Values'!AD13
CachedFormulaResultType : NUMERIC
Numeric value : 0.0
'Unformatted Values' is the name of a hidden sheet in the workbook
--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html