org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator类的使用及代码示例

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

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

XSSFFormulaEvaluator介绍

[英]Evaluates formula cells.

For performance reasons, this class keeps a cache of all previously calculated intermediate cell values. Be sure to call #clearAllCachedResultValues() if any workbook cells are changed between calls to evaluate~ methods on this class.
[中]

代码示例

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

  1. /**
  2. * Creates a XSSFFormulaEvaluator, the object that evaluates formula cells.
  3. *
  4. * @return a XSSFFormulaEvaluator instance
  5. */
  6. @Override
  7. public XSSFFormulaEvaluator createFormulaEvaluator() {
  8. return new XSSFFormulaEvaluator(workbook);
  9. }

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

  1. /**
  2. * Loops over all cells in all sheets of the supplied
  3. * workbook.
  4. * For cells that contain formulas, their formulas are
  5. * evaluated, and the results are saved. These cells
  6. * remain as formula cells.
  7. * For cells that do not contain formulas, no changes
  8. * are made.
  9. * This is a helpful wrapper around looping over all
  10. * cells, and calling evaluateFormulaCell on each one.
  11. */
  12. public void evaluateAll() {
  13. evaluateAllFormulaCells(_book, this);
  14. }

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

  1. protected CellValue getCellValueAt(int index) {
  2. if (index < 0 || index >= numOfCells) {
  3. throw new IndexOutOfBoundsException(
  4. "Index must be between 0 and " + (numOfCells - 1) + " (inclusive), given: " + index);
  5. }
  6. int firstRow = cellRangeAddress.getFirstRow();
  7. int firstCol = cellRangeAddress.getFirstColumn();
  8. int lastCol = cellRangeAddress.getLastColumn();
  9. int width = lastCol - firstCol + 1;
  10. int rowIndex = firstRow + index / width;
  11. int cellIndex = firstCol + index % width;
  12. XSSFRow row = sheet.getRow(rowIndex);
  13. return (row == null) ? null : evaluator.evaluate(row.getCell(cellIndex));
  14. }
  15. }

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

  1. /**
  2. * Returns a formula evaluator that is loaded with the functions that
  3. * have been supplied.
  4. *
  5. * @param fileName Specifies if XSSF or HSSF should be used for
  6. * the evaluator
  7. * @return A {@link FormulaEvaluator} constructed accordingly
  8. */
  9. protected FormulaEvaluator getEvaluator(String fileName) {
  10. FormulaEvaluator evaluator;
  11. if (fileName.endsWith(".xlsx")) {
  12. if(xlsMacroList.size() > 0) {
  13. evaluator = XSSFFormulaEvaluator.create((XSSFWorkbook) workbook,
  14. null,
  15. getFunctions());
  16. }
  17. evaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook);
  18. } else {
  19. if(xlsMacroList.size() > 0) {
  20. evaluator = HSSFFormulaEvaluator.create((HSSFWorkbook)workbook,
  21. null,
  22. getFunctions());
  23. }
  24. evaluator = new HSSFFormulaEvaluator((HSSFWorkbook) workbook);
  25. }
  26. return evaluator;
  27. }

代码示例来源:origin: com.helger/ph-poi

  1. public ExcelFormulaEvaluator (@Nonnull final Workbook aWB, @Nullable final IStabilityClassifier aStability)
  2. {
  3. m_aEvaluator = aWB instanceof HSSFWorkbook ? new HSSFFormulaEvaluator ((HSSFWorkbook) aWB, aStability)
  4. : XSSFFormulaEvaluator.create ((XSSFWorkbook) aWB, aStability, null);
  5. }

代码示例来源:origin: ru.sbtqa.tag.datajack.providers/excel-provider

  1. } catch (Exception e) {
  2. LOG.debug("Failed to get raw cell value, now trying to get typified", e);
  3. switch (evaluator.evaluateFormulaCellEnum(cell)) {
  4. case BOOLEAN:
  5. value = String.valueOf(cell.getBooleanCellValue());

代码示例来源:origin: ru.sbtqa.tag.datajack.adaptors/datajack-excel-adaptor

  1. } catch (Exception e) {
  2. LOG.debug("Failed to get raw cell value, now trying to get typified", e);
  3. switch (evaluator.evaluateFormulaCell(cell)) {
  4. case Cell.CELL_TYPE_BOOLEAN:
  5. value = String.valueOf(cell.getBooleanCellValue());

代码示例来源:origin: com.phloc/phloc-poi

  1. public ExcelFormulaEvaluator (@Nonnull final Workbook aWB, @Nullable final IStabilityClassifier aStability)
  2. {
  3. m_aEvaluator = aWB instanceof HSSFWorkbook ? new HSSFFormulaEvaluator ((HSSFWorkbook) aWB, aStability)
  4. : XSSFFormulaEvaluator.create ((XSSFWorkbook) aWB, aStability, null);
  5. }

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

  1. /**
  2. * @param stabilityClassifier used to optimise caching performance. Pass <code>null</code>
  3. * for the (conservative) assumption that any cell may have its definition changed after
  4. * evaluation begins.
  5. * @param udfFinder pass <code>null</code> for default (AnalysisToolPak only)
  6. */
  7. public static XSSFFormulaEvaluator create(XSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) {
  8. return new XSSFFormulaEvaluator(workbook, stabilityClassifier, udfFinder);
  9. }

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

  1. /**
  2. * Loops over all cells in all sheets of the supplied
  3. * workbook.
  4. * For cells that contain formulas, their formulas are
  5. * evaluated, and the results are saved. These cells
  6. * remain as formula cells.
  7. * For cells that do not contain formulas, no changes
  8. * are made.
  9. * This is a helpful wrapper around looping over all
  10. * cells, and calling evaluateFormulaCell on each one.
  11. */
  12. public void evaluateAll() {
  13. evaluateAllFormulaCells(_book, this);
  14. }

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

  1. protected CellValue getCellValueAt(int index) {
  2. if (index < 0 || index >= numOfCells) {
  3. throw new IndexOutOfBoundsException(
  4. "Index must be between 0 and " + (numOfCells - 1) + " (inclusive), given: " + index);
  5. }
  6. int firstRow = cellRangeAddress.getFirstRow();
  7. int firstCol = cellRangeAddress.getFirstColumn();
  8. int lastCol = cellRangeAddress.getLastColumn();
  9. int width = lastCol - firstCol + 1;
  10. int rowIndex = firstRow + index / width;
  11. int cellIndex = firstCol + index % width;
  12. XSSFRow row = sheet.getRow(rowIndex);
  13. return (row == null) ? null : evaluator.evaluate(row.getCell(cellIndex));
  14. }
  15. }

代码示例来源:origin: com.github.almex/raildelays-batch

  1. @Override
  2. protected FormulaEvaluator doWithXSSFWorkbook(XSSFWorkbook workbook) {
  3. return new XSSFFormulaEvaluator(workbook);
  4. }
  5. }.execute();

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

  1. private Workbook getWorkBook() throws IOException {
  2. Workbook excelWorkbook;
  3. String extension = file.getName().toUpperCase(ENGLISH);
  4. try (FileInputStream excelFile = new FileInputStream(file)) {
  5. if (extension.endsWith(Extension.XLSX.value) || extension.endsWith(Extension.XLSM.value)) {
  6. excelWorkbook = new XSSFWorkbook(excelFile);
  7. XSSFFormulaEvaluator.evaluateAllFormulaCells(excelWorkbook);
  8. } else if (extension.endsWith(Extension.XLS.value)) {
  9. excelWorkbook = new HSSFWorkbook(excelFile);
  10. HSSFFormulaEvaluator.evaluateAllFormulaCells(excelWorkbook);
  11. } else {
  12. FileFormatException e = new FileFormatException(format("%s is not a valid excel file.", file.getName()));
  13. LOGGER.error(e.getMessage());
  14. throw e;
  15. }
  16. } catch (Exception e) {
  17. LOGGER.error(e.getMessage());
  18. throw e;
  19. }
  20. return excelWorkbook;
  21. }

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

  1. /**
  2. * @param stabilityClassifier used to optimise caching performance. Pass <code>null</code>
  3. * for the (conservative) assumption that any cell may have its definition changed after
  4. * evaluation begins.
  5. * @param udfFinder pass <code>null</code> for default (AnalysisToolPak only)
  6. */
  7. public static XSSFFormulaEvaluator create(XSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) {
  8. return new XSSFFormulaEvaluator(workbook, stabilityClassifier, udfFinder);
  9. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. /**
  2. * @param stabilityClassifier used to optimise caching performance. Pass <code>null</code>
  3. * for the (conservative) assumption that any cell may have its definition changed after
  4. * evaluation begins.
  5. * @param udfFinder pass <code>null</code> for default (AnalysisToolPak only)
  6. */
  7. public static XSSFFormulaEvaluator create(XSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) {
  8. return new XSSFFormulaEvaluator(workbook, stabilityClassifier, udfFinder);
  9. }

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

  1. /**
  2. * Creates a XSSFFormulaEvaluator, the object that evaluates formula cells.
  3. *
  4. * @return a XSSFFormulaEvaluator instance
  5. */
  6. @Override
  7. public XSSFFormulaEvaluator createFormulaEvaluator() {
  8. return new XSSFFormulaEvaluator(workbook);
  9. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. /**
  2. * Creates a XSSFFormulaEvaluator, the object that evaluates formula cells.
  3. *
  4. * @return a XSSFFormulaEvaluator instance
  5. */
  6. public XSSFFormulaEvaluator createFormulaEvaluator() {
  7. return new XSSFFormulaEvaluator(workbook);
  8. }

相关文章