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.
| Modifier and Type | Field and Description |
|---|---|
| private final HSSFWorkbook |
| Access | Constructor and Description |
|---|---|
| public | |
| public | HSSFFormulaEvaluator(HSSFWorkbook
The workbook to perform the formula evaluations in workbook, IStabilityClassifier used to optimise caching performance. Pass stabilityClassifier)null
for the (conservative) assumption that any cell may have its definition changed after
evaluation begins.
|
| private | HSSFFormulaEvaluator(HSSFWorkbook
The workbook to perform the formula evaluations in workbook, IStabilityClassifier used to optimise caching performance. Pass stabilityClassifier, UDFFinder null
for the (conservative) assumption that any cell may have its definition changed after
evaluation begins.pass udfFinder)null for default (AnalysisToolPak only)
|
| Modifier and Type | Method and Description |
|---|---|
| public static HSSFFormulaEvaluator | create(HSSFWorkbook
The workbook to perform the formula evaluations in workbook, IStabilityClassifier used to optimise caching performance. Pass stabilityClassifier, UDFFinder null
for the (conservative) assumption that any cell may have its definition changed after
evaluation begins.pass udfFinder)null for default (AnalysisToolPak only)
|
| protected RichTextString | createRichTextString(String str)
Implements abstract org.
|
| public void | evaluateAll()
Implements org. Loops over all cells in all sheets of the supplied workbook. |
| public static void | evaluateAllFormulaCells(HSSFWorkbook wb)
Loops over all cells in all sheets of the supplied workbook. |
| public static void | evaluateAllFormulaCells(Workbook wb)
Hides org. Loops over all cells in all sheets of the supplied workbook. |
| protected CellValue | evaluateFormulaCellValue(Cell
The cell with the formula cell)Implements abstract org. Returns a CellValue wrapper around the supplied ValueEval instance. |
| public HSSFCell | evaluateInCell(Cell
The cell)Cell to evaluate and modify.Overrides org. Implements org. If cell contains formula, it evaluates the formula, and puts the formula result back into the cell, in place of the old formula. |
| public void | notifyDeleteCell(HSSFCell cell)
Should be called to tell the cell value cache that the specified cell has just been deleted. |
| public void | notifyDeleteCell(Cell cell)
Implements org. 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 |
| public void | notifySetFormula(Cell cell)
Implements org. Should be called to tell the cell value cache that the specified (value or formula) cell has changed. |
| public void | notifyUpdateCell(HSSFCell cell)
Should be called to tell the cell value cache that the specified (value or formula) cell has changed. |
| public void | notifyUpdateCell(Cell cell)
Implements org. Should be called to tell the cell value cache that the specified (value or formula) cell has changed. |
| public void | setDebugEvaluationOutputForNextEval(boolean
whether to perform detailed output value)Overrides org. Implements org. Perform detailed output of formula evaluation for next evaluation only? |
| public void | setIgnoreMissingWorkbooks(boolean
whether to ignore missing references to external workbooks ignore)Overrides org. Implements org. Whether to ignore missing references to external workbooks and use cached formula results in the main workbook instead. |
| public static void | setupEnvironment(String[]
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, HSSFFormulaEvaluator[] all evaluators for the full set of workbooks required by the formulas. evaluators)Coordinates several formula evaluators together so that formulas that involve external references can be evaluated. |
| public void | setupReferencedWorkbooks(Map<String, FormulaEvaluator>
Map of workbook names (no square brackets) to an evaluator on that workbook evaluators)Overrides org. Implements org. Sets up the Formula Evaluator to be able to reference and resolve links to other workbooks, eg [Test.xls]Sheet1!A1. |
| _book | back to summary |
|---|---|
| private final HSSFWorkbook _book | |
| HSSFFormulaEvaluator | back to summary |
|---|---|
| public HSSFFormulaEvaluator(HSSFWorkbook workbook) | |
| HSSFFormulaEvaluator | back to summary |
|---|---|
public HSSFFormulaEvaluator(HSSFWorkbook workbook, IStabilityClassifier stabilityClassifier)
| |
| HSSFFormulaEvaluator | back to summary |
|---|---|
private HSSFFormulaEvaluator(HSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
| |
| create | back to summary |
|---|---|
public static HSSFFormulaEvaluator create(HSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
| |
| createRichTextString | back to summary |
|---|---|
| protected RichTextString createRichTextString(String str) Implements abstract org.
| |
| evaluateAll | back to summary |
|---|---|
| public void evaluateAll() Implements org. 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.
| |
| evaluateAllFormulaCells | back to summary |
|---|---|
| public static void evaluateAllFormulaCells(HSSFWorkbook wb) 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. | |
| evaluateAllFormulaCells | back to summary |
|---|---|
| public static void evaluateAllFormulaCells(Workbook wb) Hides org. 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. | |
| evaluateFormulaCellValue | back to summary |
|---|---|
| protected CellValue evaluateFormulaCellValue(Cell cell) Implements abstract org. Returns a CellValue wrapper around the supplied ValueEval instance. | |
| evaluateInCell | back to summary |
|---|---|
| public HSSFCell evaluateInCell(Cell cell) Overrides org. Implements org. Doc from org. If cell contains formula, it evaluates the formula, and
puts the formula result back into the cell, in place
of the old formula.
Else if cell does not contain formula, this method leaves
the cell unchanged.
Note that the same instance of 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)}
| |
| notifyDeleteCell | back to summary |
|---|---|
| public void notifyDeleteCell(HSSFCell cell) Should be called to tell the cell value cache that the specified cell has just been deleted. Failure to call this method after changing cell values will cause incorrect behaviour of the evaluate~ methods of this class | |
| notifyDeleteCell | back to summary |
|---|---|
| public void notifyDeleteCell(Cell cell) Implements org. Doc from org. 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
| |
| notifySetFormula | back to summary |
|---|---|
| public void notifySetFormula(Cell cell) Implements org. Should be called to tell the cell value cache that the specified (value or formula) cell has changed. Failure to call this method after changing cell values will cause incorrect behaviour of the evaluate~ methods of this class
| |
| notifyUpdateCell | back to summary |
|---|---|
| public void notifyUpdateCell(HSSFCell cell) Should be called to tell the cell value cache that the specified (value or formula) cell has changed. Failure to call this method after changing cell values will cause incorrect behaviour of the evaluate~ methods of this class | |
| notifyUpdateCell | back to summary |
|---|---|
| public void notifyUpdateCell(Cell cell) Implements org. Doc from org. Should be called to tell the cell value cache that the specified (value or formula) cell has changed. Failure to call this method after changing cell values will cause incorrect behaviour of the evaluate~ methods of this class
| |
| setDebugEvaluationOutputForNextEval | back to summary |
|---|---|
| public void setDebugEvaluationOutputForNextEval(boolean value) Overrides org. Implements org. Doc from org. Perform detailed output of formula evaluation for next evaluation only? Is for developer use only (also developers using POI for their XLS files). Log-Level WARN is for basic info, INFO for detailed information. These quite high levels are used because you have to explicitly enable this specific logging.
| |
| setIgnoreMissingWorkbooks | back to summary |
|---|---|
| public void setIgnoreMissingWorkbooks(boolean ignore) Overrides org. Implements org. Doc from org. Whether to ignore missing references to external workbooks and use cached formula results in the main workbook instead. 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:
| |
| setupEnvironment | back to summary |
|---|---|
| public static void setupEnvironment(String[] workbookNames, HSSFFormulaEvaluator[] evaluators) Coordinates several formula evaluators together so that formulas that involve external references can be evaluated.
| |
| setupReferencedWorkbooks | back to summary |
|---|---|
| public void setupReferencedWorkbooks(Map<String, FormulaEvaluator> evaluators) Overrides org. Implements org. Doc from org. Sets up the Formula Evaluator to be able to reference and resolve links to other workbooks, eg [Test.xls]Sheet1!A1. 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.
| |