org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.evaluateAllFormulaCells()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(273)

本文整理了Java中org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.evaluateAllFormulaCells()方法的一些代码示例,展示了XSSFFormulaEvaluator.evaluateAllFormulaCells()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSSFFormulaEvaluator.evaluateAllFormulaCells()方法的具体详情如下:
包路径:org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator
类名称:XSSFFormulaEvaluator
方法名:evaluateAllFormulaCells

XSSFFormulaEvaluator.evaluateAllFormulaCells介绍

[英]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.
[中]在所提供工作簿的所有工作表中的所有单元格上循环。对于包含公式的单元格,将计算其公式,并保存结果。这些细胞仍然是公式细胞。对于不包含公式的单元格,不会进行任何更改。这是一个有用的包装器,可以在所有单元格上循环,并在每个单元格上调用evaluateFormulaCell。

代码示例

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
 * 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);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * 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);
}

代码示例来源:origin: org.bitbucket.iamkenos/cissnei-commons

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;
}

相关文章

微信公众号

最新文章

更多