/** * Loops over all cells in all sheets of the supplied * workbook. * For cells that contain formulas, their formulas are * evaluated, and the results are saved. These cells * remain as formula cells. * For cells that do not contain formulas, no changes * are made. * This is a helpful wrapper around looping over all * cells, and calling evaluateFormulaCell on each one. */ public void evaluateAll() { evaluateAllFormulaCells(_book, this); }
/** * Loops over all cells in all sheets of the supplied * workbook. * For cells that contain formulas, their formulas are * evaluated, and the results are saved. These cells * remain as formula cells. * For cells that do not contain formulas, no changes * are made. * This is a helpful wrapper around looping over all * cells, and calling evaluateFormulaCell on each one. */ public void evaluateAll() { evaluateAllFormulaCells(_book, this); }
private Workbook getWorkBook() throws IOException { Workbook excelWorkbook; String extension = file.getName().toUpperCase(ENGLISH); try (FileInputStream excelFile = new FileInputStream(file)) { if (extension.endsWith(Extension.XLSX.value) || extension.endsWith(Extension.XLSM.value)) { excelWorkbook = new XSSFWorkbook(excelFile); XSSFFormulaEvaluator.evaluateAllFormulaCells(excelWorkbook); } else if (extension.endsWith(Extension.XLS.value)) { excelWorkbook = new HSSFWorkbook(excelFile); HSSFFormulaEvaluator.evaluateAllFormulaCells(excelWorkbook); } else { FileFormatException e = new FileFormatException(format("%s is not a valid excel file.", file.getName())); LOGGER.error(e.getMessage()); throw e; } } catch (Exception e) { LOGGER.error(e.getMessage()); throw e; } return excelWorkbook; }