set cell Formula :
IFERROR("FY"&YEAR("2019/04/26")-"6","NA")
look cellType:
evaluateFormulaCell:
get cell value:
but :
and I try this:
update:
@Test
public void ifERRORTest() {
Workbook workbook = new XSSFWorkbook();
workbook.setForceFormulaRecalculation(true);
Sheet sheet = workbook.createSheet("1");
Cell cell = sheet.createRow(0).createCell(0);
cell.setCellFormula("IFERROR(\"FY\"&2019-\"1\",\"NA\")");
// cell.setCellFormula("YEAR(\"2018-01-01\")");
FormulaEvaluator formulaEvaluator = workbook.getCreationHelper().createFormulaEvaluator();
formulaEvaluator.evaluateInCell(cell);
System.out.println(cell.getCellType());
System.out.println(cell.getStringCellValue());
}
this is work. so YEAR("2019/01/01") not work