public final class XSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator
For performance reasons, this class keeps a cache of all previously calculated intermediate cell values. Be sure to call BaseFormulaEvaluator.clearAllCachedResultValues()
if any workbook cells are changed between calls to evaluate~ methods on this class.
_bookEvaluator
Modifier | Constructor and Description |
---|---|
|
XSSFFormulaEvaluator(XSSFWorkbook workbook) |
protected |
XSSFFormulaEvaluator(XSSFWorkbook workbook, WorkbookEvaluator bookEvaluator) |
Modifier and Type | Method and Description |
---|---|
static XSSFFormulaEvaluator |
create(XSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) |
void |
evaluateAll()
Loops over all cells in all sheets of the supplied workbook.
(循环提供的工作簿的所有工作表中的所有单元格。)
|
static void |
evaluateAllFormulaCells(XSSFWorkbook wb)
Loops over all cells in all sheets of the supplied workbook.
(循环提供的工作簿的所有工作表中的所有单元格。)
|
XSSFCell |
evaluateInCell(Cell cell)
If cell contains formula, it evaluates the formula, and puts the formula result back into the cell, in place of the old formula.
(如果单元格包含公式,它会计算公式,并将公式结果放回单元格中,以代替旧公式。)
|
void |
notifyDeleteCell(Cell cell)
Should be called to tell the cell value cache that the specified cell has just become a formula cell, or the formula text has changed
(应该调用来告诉单元格值缓存指定单元格刚刚变成了公式单元格,或者公式文本发生了变化)
|
void |
notifySetFormula(Cell cell)
Should be called to tell the cell value cache that the specified (value or formula) cell has changed.
(应该调用以告诉单元格值缓存指定的(值或公式)单元格已更改。)
|
void |
notifyUpdateCell(Cell cell)
Should be called to tell the cell value cache that the specified (value or formula) cell has changed.
(应该调用以告诉单元格值缓存指定的(值或公式)单元格已更改。)
|
protected EvaluationCell |
toEvaluationCell(Cell cell)
Turns a XSSFCell into a XSSFEvaluationCell
(将 XSSFCell 转换为 XSSFEvaluationCell)
|
createRichTextString, evaluateFormulaCellValue, setCellType
_getWorkbookEvaluator, clearAllCachedResultValues, evaluate, evaluateAllFormulaCells, evaluateAllFormulaCells, evaluateFormulaCell, getEvaluationWorkbook, setCellType, setCellValue, setDebugEvaluationOutputForNextEval, setIgnoreMissingWorkbooks, setupEnvironment, setupReferencedWorkbooks
public XSSFFormulaEvaluator(XSSFWorkbook workbook)
protected XSSFFormulaEvaluator(XSSFWorkbook workbook, WorkbookEvaluator bookEvaluator)
public static XSSFFormulaEvaluator create(XSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
stabilityClassifier
- used to optimise caching performance. Pass
null
for the (conservative) assumption that any cell may have its definition changed after evaluation begins.
(stableClassifier - 用于优化缓存性能。为(保守的)假设传递 null ,即任何单元格在评估开始后可能会更改其定义。)
udfFinder
- pass
null
for default (AnalysisToolPak only)
(udfFinder - 传递 null 为默认值(仅限AnalysisToolPak))
public void notifySetFormula(Cell cell)
FormulaEvaluator
public void notifyDeleteCell(Cell cell)
FormulaEvaluator
public void notifyUpdateCell(Cell cell)
FormulaEvaluator
public static void evaluateAllFormulaCells(XSSFWorkbook wb)
public XSSFCell evaluateInCell(Cell cell)
BaseFormulaEvaluator
Cell
is returned to allow chained calls like:
int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType();Be aware that your cell value will be changed to hold the result of the formula. If you simply want the formula value computed for you, use
BaseFormulaEvaluator.evaluateFormulaCell(Cell)
}
(如果单元格包含公式,它会计算公式,并将公式结果放回单元格中,以代替旧公式。否则,如果单元格不包含公式,则此方法使单元格保持不变。请注意,返回相同的 Cell 实例以允许链式调用,例如: int evaluateCellType = evaluator.evaluateInCell(cell).getCellType();请注意,您的单元格值将更改为保存公式的结果。如果您只想为您计算公式值,请使用 BaseFormulaEvaluator.evaluateFormulaCell(Cell)})
evaluateInCell
in interface
FormulaEvaluator
(接口 FormulaEvaluator 中的 evaluateInCell)
evaluateInCell
in class
BaseFormulaEvaluator
cell
- The
Cell
to evaluate and modify.
(cell - 要评估和修改的 Cell。)
cell
that was passed in, allowing for chained calls
(传入的单元格,允许链式调用)
public void evaluateAll()
protected EvaluationCell toEvaluationCell(Cell cell)
toEvaluationCell
in class
BaseXSSFFormulaEvaluator
(类 BaseXSSFFormulaEvaluator 中的 toEvaluationCell)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.