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

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

本文整理了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

/**
 * Creates a XSSFFormulaEvaluator, the object that evaluates formula cells.
 *
 * @return a XSSFFormulaEvaluator instance
 */
@Override
public XSSFFormulaEvaluator createFormulaEvaluator() {
  return new XSSFFormulaEvaluator(workbook);
}

代码示例来源: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.poi/poi-ooxml

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

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

/**
 * Returns a formula evaluator that is loaded with the functions that
 * have been supplied.
 *
 * @param fileName Specifies if XSSF or HSSF should be used for
 *                 the evaluator
 * @return A {@link FormulaEvaluator} constructed accordingly
 */
protected FormulaEvaluator getEvaluator(String fileName) {
  FormulaEvaluator evaluator;
  if (fileName.endsWith(".xlsx")) {
    if(xlsMacroList.size() > 0) {
      evaluator = XSSFFormulaEvaluator.create((XSSFWorkbook) workbook,
                           null,
                           getFunctions());
    }
    evaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook);
  } else {
    if(xlsMacroList.size() > 0) {
      evaluator = HSSFFormulaEvaluator.create((HSSFWorkbook)workbook,
                           null,
                           getFunctions());
    }
    evaluator = new HSSFFormulaEvaluator((HSSFWorkbook) workbook);
  }
  return evaluator;
}

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

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

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

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

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

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

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

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

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

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

代码示例来源: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.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

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

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

@Override
  protected FormulaEvaluator doWithXSSFWorkbook(XSSFWorkbook workbook) {
    return new XSSFFormulaEvaluator(workbook);
  }
}.execute();

代码示例来源: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;
}

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

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

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

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

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

/**
 * Creates a XSSFFormulaEvaluator, the object that evaluates formula cells.
 *
 * @return a XSSFFormulaEvaluator instance
 */
@Override
public XSSFFormulaEvaluator createFormulaEvaluator() {
  return new XSSFFormulaEvaluator(workbook);
}

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

/**
 * Creates a XSSFFormulaEvaluator, the object that evaluates formula cells.
 *
 * @return a XSSFFormulaEvaluator instance
 */
public XSSFFormulaEvaluator createFormulaEvaluator() {
  return new XSSFFormulaEvaluator(workbook);
}

相关文章

微信公众号

最新文章

更多