public abstract class BaseFormulaEvaluator extends java.lang.Object implements FormulaEvaluator, WorkbookEvaluatorProvider
Modifier and Type | Field and Description |
---|---|
protected WorkbookEvaluator |
_bookEvaluator |
Modifier | Constructor and Description |
---|---|
protected |
BaseFormulaEvaluator(WorkbookEvaluator bookEvaluator) |
Modifier and Type | Method and Description |
---|---|
WorkbookEvaluator |
_getWorkbookEvaluator()
Provide the underlying WorkbookEvaluator
(提供底层 WorkbookEvaluator)
|
void |
clearAllCachedResultValues()
Should be called whenever there are major changes (e.g.
(每当有重大变化时都应该调用(例如)
|
protected abstract RichTextString |
createRichTextString(java.lang.String str) |
CellValue |
evaluate(Cell cell)
If cell contains a formula, the formula is evaluated and returned, else the CellValue simply copies the appropriate cell value from the cell and also its cell type.
(如果单元格包含公式,则计算并返回公式,否则 CellValue 只是从单元格中复制适当的单元格值及其单元格类型。)
|
static void |
evaluateAllFormulaCells(Workbook wb)
Loops over all cells in all sheets of the supplied workbook.
(循环提供的工作簿的所有工作表中的所有单元格。)
|
protected static void |
evaluateAllFormulaCells(Workbook wb, FormulaEvaluator evaluator) |
CellType |
evaluateFormulaCell(Cell cell)
If cell contains formula, it evaluates the formula, and saves the result of the formula.
(如果单元格包含公式,它会计算公式,并保存公式的结果。)
|
protected abstract CellValue |
evaluateFormulaCellValue(Cell cell) |
Cell |
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.
(如果单元格包含公式,它会计算公式,并将公式结果放回单元格中,以代替旧公式。)
|
protected EvaluationWorkbook |
getEvaluationWorkbook()
internal use
(内部使用)
|
protected void |
setCellType(Cell cell, CellType cellType)
Override if a different variation is needed, e.g.
(如果需要不同的变化,则覆盖,例如)
|
protected void |
setCellType(Cell cell, CellValue cv)
Set the cell type based on the computed cell type as part of a formula evaluation.
(作为公式评估的一部分,根据计算的单元格类型设置单元格类型。)
|
protected void |
setCellValue(Cell cell, CellValue cv) |
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, BaseFormulaEvaluator[] 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。)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
evaluateAll, notifyDeleteCell, notifySetFormula, notifyUpdateCell
protected final WorkbookEvaluator _bookEvaluator
protected BaseFormulaEvaluator(WorkbookEvaluator bookEvaluator)
public static void setupEnvironment(java.lang.String[] workbookNames, BaseFormulaEvaluator[] 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)
evaluators
- Map of workbook names (no square brackets) to an evaluator on that workbook
(evaluators - 工作簿名称(无方括号)到该工作簿上的评估者的映射)
public WorkbookEvaluator _getWorkbookEvaluator()
WorkbookEvaluatorProvider
_getWorkbookEvaluator
in interface
WorkbookEvaluatorProvider
(接口 WorkbookEvaluatorProvider 中的 _getWorkbookEvaluator)
protected EvaluationWorkbook getEvaluationWorkbook()
public void clearAllCachedResultValues()
clearAllCachedResultValues
in interface
FormulaEvaluator
(接口 FormulaEvaluator 中的 clearAllCachedResultValues)
public CellValue evaluate(Cell cell)
evaluate
in interface
FormulaEvaluator
(在接口 FormulaEvaluator 中求值)
cell
- may be
null
signifying that the cell is not present (or blank)
(单元格 - 可能为空,表示该单元格不存在(或空白))
null
if the supplied cell is
null
or blank
(如果提供的单元格为空或空白,则为空)
public Cell evaluateInCell(Cell cell)
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
evaluateFormulaCell(Cell)
}
(如果单元格包含公式,它会计算公式,并将公式结果放回单元格中,以代替旧公式。否则,如果单元格不包含公式,则此方法使单元格保持不变。请注意,返回相同的 Cell 实例以允许链式调用,例如: int evaluateCellType = evaluator.evaluateInCell(cell).getCellType();请注意,您的单元格值将更改为保存公式的结果。如果您只想为您计算公式值,请使用 evaluateFormulaCell(Cell)})
evaluateInCell
in interface
FormulaEvaluator
(接口 FormulaEvaluator 中的 evaluateInCell)
cell
- The
Cell
to evaluate and modify.
(cell - 要评估和修改的 Cell。)
cell
that was passed in, allowing for chained calls
(传入的单元格,允许链式调用)
public CellType evaluateFormulaCell(Cell cell)
CellType evaluatedCellType = evaluator.evaluateFormulaCell(cell);Be aware that your cell will hold both the formula, and the result. If you want the cell replaced with the result of the formula, use
evaluate(org.apache.poi.ss.usermodel.Cell)
}
(如果单元格包含公式,它会计算公式,并保存公式的结果。该单元格保留为公式单元格。否则,如果单元格不包含公式,则此方法使单元格保持不变。请注意,返回的是公式结果的类型,因此您知道公式中还存储了什么样的值。 CellType 评估CellType = evaluator.evaluateFormulaCell(cell);请注意,您的单元格将包含公式和结果。如果要将单元格替换为公式的结果,请使用 evaluate(org.apache.poi.ss.usermodel.Cell) })
evaluateFormulaCell
in interface
FormulaEvaluator
(接口 FormulaEvaluator 中的 evaluateFormulaCell)
cell
- The cell to evaluate
(cell - 要评估的单元格)
CellType._NONE
rather than throwing an exception.
(公式结果的类型(单元格的类型仍然为 CellType.FORMULA)如果单元格不是公式单元格,则返回 CellType._NONE 而不是抛出异常。)
protected void setCellType(Cell cell, CellValue cv)
cell
- The Cell to populate
(cell - 要填充的单元格)
cv
- The CellValue to read the result type from
(cv - 要从中读取结果类型的 CellValue)
protected void setCellType(Cell cell, CellType cellType)
cell
- The Cell to populate
(cell - 要填充的单元格)
cellType
- The wanted type for this Cell
(cellType - 此 Cell 所需的类型)
protected abstract RichTextString createRichTextString(java.lang.String str)
public static void evaluateAllFormulaCells(Workbook wb)
protected static void evaluateAllFormulaCells(Workbook wb, FormulaEvaluator evaluator)
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)
ignore
- whether to ignore missing references to external workbooks
(ignore - 是否忽略对外部工作簿的缺失引用)
public void setDebugEvaluationOutputForNextEval(boolean value)
setDebugEvaluationOutputForNextEval
in interface
FormulaEvaluator
(接口 FormulaEvaluator 中的 setDebugEvaluationOutputForNextEval)
value
- whether to perform detailed output
(value - 是否进行详细输出)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.