public class HSSFFormulaEvaluator extends BaseFormulaEvaluator
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
Constructor and Description |
---|
HSSFFormulaEvaluator(HSSFWorkbook workbook) |
HSSFFormulaEvaluator(HSSFWorkbook workbook, IStabilityClassifier stabilityClassifier) |
Modifier and Type | Method and Description |
---|---|
static HSSFFormulaEvaluator |
create(HSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) |
protected RichTextString |
createRichTextString(java.lang.String str) |
void |
evaluateAll()
Loops over all cells in all sheets of the supplied workbook.
(循环提供的工作簿的所有工作表中的所有单元格。)
|
static void |
evaluateAllFormulaCells(HSSFWorkbook wb)
Loops over all cells in all sheets of the supplied workbook.
(循环提供的工作簿的所有工作表中的所有单元格。)
|
static void |
evaluateAllFormulaCells(Workbook wb)
Loops over all cells in all sheets of the supplied workbook.
(循环提供的工作簿的所有工作表中的所有单元格。)
|
protected CellValue |
evaluateFormulaCellValue(Cell cell)
Returns a CellValue wrapper around the supplied ValueEval instance.
(返回围绕提供的 ValueEval 实例的 CellValue 包装器。)
|
HSSFCell |
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 |
notifyDeleteCell(HSSFCell cell)
Should be called to tell the cell value cache that the specified cell has just been deleted.
(应该调用来告诉单元格值缓存指定的单元格刚刚被删除。)
|
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.
(应该调用以告诉单元格值缓存指定的(值或公式)单元格已更改。)
|
void |
notifyUpdateCell(HSSFCell cell)
Should be called to tell the cell value cache that the specified (value or formula) cell has changed.
(应该调用以告诉单元格值缓存指定的(值或公式)单元格已更改。)
|
void |
setDebugEvaluationOutputForNextEval(boolean value)
Perform detailed output of formula evaluation for next evaluation only? Is for developer use only (also developers using POI for their XLS files).
(只为下次评估执行公式评估的详细输出?仅供开发人员使用(开发人员也将 POI 用于他们的 XLS 文件)。)
|
void |
setIgnoreMissingWorkbooks(boolean ignore)
Whether to ignore missing references to external workbooks and use cached formula results in the main workbook instead.
(是否忽略对外部工作簿的缺失引用并在主工作簿中使用缓存的公式结果。)
|
static void |
setupEnvironment(java.lang.String[] workbookNames, HSSFFormulaEvaluator[] evaluators)
Coordinates several formula evaluators together so that formulas that involve external references can be evaluated.
(将多个公式评估器协调在一起,以便可以评估涉及外部引用的公式。)
|
void |
setupReferencedWorkbooks(java.util.Map<java.lang.String,FormulaEvaluator> evaluators)
Sets up the Formula Evaluator to be able to reference and resolve links to other workbooks, eg [Test.xls]Sheet1!A1.
(设置公式评估器以能够引用和解析指向其他工作簿的链接,例如 [Test.xls]Sheet1!A1。)
|
_getWorkbookEvaluator, clearAllCachedResultValues, evaluate, evaluateAllFormulaCells, evaluateFormulaCell, getEvaluationWorkbook, setCellType, setCellType, setCellValue, setupEnvironment
public HSSFFormulaEvaluator(HSSFWorkbook workbook)
public HSSFFormulaEvaluator(HSSFWorkbook workbook, IStabilityClassifier stabilityClassifier)
workbook
- The workbook to perform the formula evaluations in
(工作簿 - 执行公式评估的工作簿)
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 ,即任何单元格在评估开始后可能会更改其定义。)
public static HSSFFormulaEvaluator create(HSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
workbook
- The workbook to perform the formula evaluations in
(工作簿 - 执行公式评估的工作簿)
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))
protected RichTextString createRichTextString(java.lang.String str)
createRichTextString
in class
BaseFormulaEvaluator
(类 BaseFormulaEvaluator 中的 createRichTextString)
public static void setupEnvironment(java.lang.String[] workbookNames, HSSFFormulaEvaluator[] evaluators)
workbookNames
- the simple file names used to identify the workbooks in formulas with external links (for example "MyData.xls" as used in a formula "[MyData.xls]Sheet1!A1")
(workbookNames - 用于在具有外部链接的公式中标识工作簿的简单文件名(例如,公式“[MyData.xls]Sheet1!A1”中使用的“MyData.xls”))
evaluators
- all evaluators for the full set of workbooks required by the formulas.
(评估者 - 公式所需的全套工作簿的所有评估者。)
public void setupReferencedWorkbooks(java.util.Map<java.lang.String,FormulaEvaluator> evaluators)
FormulaEvaluator
For a workbook referenced as [Test.xls]Sheet1!A1, you should supply a map containing the key Test.xls (no square brackets), and an open FormulaEvaluator onto that Workbook.
(设置公式评估器以能够引用和解析指向其他工作簿的链接,例如 [Test.xls]Sheet1!A1。对于引用为 [Test.xls]Sheet1!A1 的工作簿,您应该提供一个包含键 Test.xls(无方括号)的映射,以及该工作簿上的打开的 FormulaEvaluator。)setupReferencedWorkbooks
in interface
FormulaEvaluator
(接口 FormulaEvaluator 中的 setupReferencedWorkbooks)
setupReferencedWorkbooks
in class
BaseFormulaEvaluator
evaluators
- Map of workbook names (no square brackets) to an evaluator on that workbook
(evaluators - 工作簿名称(无方括号)到该工作簿上的评估者的映射)
public void notifyUpdateCell(HSSFCell cell)
public void notifyUpdateCell(Cell cell)
FormulaEvaluator
public void notifyDeleteCell(HSSFCell cell)
public void notifyDeleteCell(Cell cell)
FormulaEvaluator
public void notifySetFormula(Cell cell)
public HSSFCell 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 static void evaluateAllFormulaCells(HSSFWorkbook wb)
public static void evaluateAllFormulaCells(Workbook wb)
public void evaluateAll()
protected CellValue evaluateFormulaCellValue(Cell cell)
evaluateFormulaCellValue
in class
BaseFormulaEvaluator
(类 BaseFormulaEvaluator 中的 evaluateFormulaCellValue)
cell
- The cell with the formula
(单元格 - 带有公式的单元格)
public void setIgnoreMissingWorkbooks(boolean ignore)
In some cases external workbooks referenced by formulas in the main workbook are not available. With this method you can control how POI handles such missing references:
CollaboratingWorkbooksEnvironment.WorkbookNotFoundException
if an external reference cannot be resolvedsetIgnoreMissingWorkbooks
in interface
FormulaEvaluator
(接口 FormulaEvaluator 中的 setIgnoreMissingWorkbooks)
setIgnoreMissingWorkbooks
in class
BaseFormulaEvaluator
ignore
- whether to ignore missing references to external workbooks
(ignore - 是否忽略对外部工作簿的缺失引用)
public void setDebugEvaluationOutputForNextEval(boolean value)
setDebugEvaluationOutputForNextEval
in interface
FormulaEvaluator
(接口 FormulaEvaluator 中的 setDebugEvaluationOutputForNextEval)
setDebugEvaluationOutputForNextEval
in class
BaseFormulaEvaluator
value
- whether to perform detailed output
(value - 是否进行详细输出)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.