我正在尝试使用POI XSSF来评估一些Excel公式.这些值不必保存,我可能需要计算很多公式,所以我试图在同一个单元格中完成所有这些.
问题是即使在我重新计算之后,单元格值似乎仍然卡在输入的第一个公式上
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());
Run Code Online (Sandbox Code Playgroud)
这两次输出40822.0 40822.0(excel相当于10/6/2011),而不是重新评估新公式.