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 EvaluationCache | |
| private CollaboratingWorkbooksEnvironment | |
| private final IEvaluationListener | |
| private boolean | |
| private final Map | |
| private final Map | |
| private final IStabilityClassifier | |
| private final AggregatingUDFFinder | |
| private final EvaluationWorkbook | |
| private int | _workbookIx
part of cache entry key (useful when evaluating multiple workbooks) |
| private boolean | dbgEvaluationOutputForNextEval
whether print detailed messages about the next formula evaluation |
| private int | |
| private static final Logger | |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| public | WorkbookEvaluator(EvaluationWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder
pass udfFinder)null for default (AnalysisToolPak only)
|
| pack-priv | WorkbookEvaluator(EvaluationWorkbook workbook, IEvaluationListener evaluationListener, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
|
| Modifier and Type | Method and Description |
|---|---|
| private NotImplementedException | addExceptionInfo(NotImplementedException inner, int sheetIndex, int rowIndex, int columnIndex)
Adds the current cell reference to the exception for easier debugging. |
| private boolean | Returns: true if any Ptg references were shiftedcell within the region to use. target, CellRangeAddressBase containing the cell, OR, for conditional format rules with multiple ranges, the region with the top-left-most cell region)Adjust formula relative references by the offset between the start of the given region and the given target cell. |
| pack-priv void | attachToEnvironment(CollaboratingWorkbooksEnvironment collaboratingWorkbooksEnvironment, EvaluationCache cache, int workbookIx)
|
| public void | clearAllCachedResultValues()
Should be called whenever there are changes to input cells in the evaluated workbook. |
| private static int | Returns: the number of tokens (starting fromstartIndex+1) that need to be skipped
to achieve the specified distInBytes skip distance.Calculates the number of tokens that the evaluator should skip upon reaching a tAttrSkip. |
| private static ValueEval | Returns: aNumberEval, StringEval, BoolEval, or
ErrorEval. Never null. BlankEval is
converted to NumberEval#ZERODereferences a single value from any AreaEval or RefEval evaluation result. |
| public static ValueEval | Returns: aNumberEval, StringEval, BoolEval, or
ErrorEval. Never null. BlankEval is
converted to NumberEval#ZERODereferences a single value from any AreaEval or RefEval evaluation result. |
| pack-priv void | detachFromEnvironment()
Discards the current workbook environment and attaches to the default 'empty' environment. |
| public ValueEval | |
| public ValueEval | Returns: valueto evaluate formula, CellReference defines the optional sheet and row/column base for the formula, if it is relative ref)Evaluate a formula outside a cell value, e.g. conditional format rules or data validation expressions |
| public ValueEval | Returns: valueThe formula to evaluate formula, CellReference cell context for the operation target, CellRangeAddressBase containing the cell region)Some expressions need to be evaluated in terms of an offset from the top left corner of a region, such as some data validation and conditional format expressions, when those constraints apply to contiguous cells. |
| private ValueEval | evaluate(String formula, CellReference target, CellRangeAddressBase region, FormulaType formulaType)
|
| private ValueEval | evaluateAny(EvaluationCell srcCell, int sheetIndex, int rowIndex, int columnIndex, EvaluationTracker tracker)
|
| pack-priv ValueEval | |
| public ValueEval | Returns: ValueEval for one or more valuesThe formula to evaluate formula, CellReference cell context for the operation target, CellRangeAddressBase containing the cell region)Some expressions need to be evaluated in terms of an offset from the top left corner of a region, such as some data validation and conditional format expressions, when those constraints apply to contiguous cells. |
| pack-priv ValueEval | evaluateNameFormula(Ptg[] ptgs, OperationEvaluationContext ec)
YK: Used by OperationEvaluationContext to resolve indirect names. |
| pack-priv ValueEval | evaluateReference(EvaluationSheet sheet, int sheetIndex, int rowIndex, int columnIndex, EvaluationTracker tracker)
Used by the lazy ref evals whenever they need to get the value of a contained cell. |
| public FreeRefFunction | |
| pack-priv CollaboratingWorkbooksEnvironment | |
| private ValueEval | |
| private ValueEval | getEvalForPtg(Ptg ptg, OperationEvaluationContext ec)
returns an appropriate Eval impl instance for the Ptg. |
| pack-priv IEvaluationListener | |
| pack-priv EvaluationName | |
| public static Collection | Returns: names of functions NOT supported by POIReturn a collection of functions that POI does not support |
| pack-priv WorkbookEvaluator | Returns: the evaluator for another workbook which is part of the sameCollaboratingWorkbooksEnvironment
|
| pack-priv EvaluationSheet | |
| private int | |
| pack-priv int | Returns: -1 if sheet with specified name does not existCase-insensitive. |
| pack-priv int | |
| pack-priv String | |
| public static Collection | Returns: names of functions supported by POIReturn a collection of functions that POI can evaluate |
| pack-priv static ValueEval | |
| pack-priv EvaluationWorkbook | |
| public boolean | |
| public boolean | |
| public void | notifyDeleteCell(EvaluationCell cell)
Should be called to tell the cell value cache that the specified cell has just been deleted. |
| public void | notifyUpdateCell(EvaluationCell cell)
Should be called to tell the cell value cache that the specified (value or formula) cell has changed. |
| private ValueEval | |
| public static void | registerFunction(String
the function name name, FreeRefFunction the function to register func)Register a ATP function in runtime. |
| public static void | registerFunction(String
the function name name, Function the function to register func)Register a function in runtime. |
| public void | |
| public void | setIgnoreMissingWorkbooks(boolean
whether to ignore missing references to external workbooks ignore)Whether to ignore missing references to external workbooks and use cached formula results in the main workbook instead. |
| _cache | back to summary |
|---|---|
| private EvaluationCache _cache | |
| _collaboratingWorkbookEnvironment | back to summary |
|---|---|
| private CollaboratingWorkbooksEnvironment _collaboratingWorkbookEnvironment | |
| _evaluationListener | back to summary |
|---|---|
| private final IEvaluationListener _evaluationListener | |
| _ignoreMissingWorkbooks | back to summary |
|---|---|
| private boolean _ignoreMissingWorkbooks | |
| _sheetIndexesByName | back to summary |
|---|---|
| private final Map<String, Integer> _sheetIndexesByName | |
| _sheetIndexesBySheet | back to summary |
|---|---|
| private final Map<EvaluationSheet, Integer> _sheetIndexesBySheet | |
| _stabilityClassifier | back to summary |
|---|---|
| private final IStabilityClassifier _stabilityClassifier | |
| _udfFinder | back to summary |
|---|---|
| private final AggregatingUDFFinder _udfFinder | |
| _workbook | back to summary |
|---|---|
| private final EvaluationWorkbook _workbook | |
| _workbookIx | back to summary |
|---|---|
| private int _workbookIx part of cache entry key (useful when evaluating multiple workbooks) | |
| dbgEvaluationOutputForNextEval | back to summary |
|---|---|
| private boolean dbgEvaluationOutputForNextEval whether print detailed messages about the next formula evaluation | |
| dbgEvaluationOutputIndent | back to summary |
|---|---|
| private int dbgEvaluationOutputIndent | |
| EVAL_LOG | back to summary |
|---|---|
| private static final Logger EVAL_LOG | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| WorkbookEvaluator | back to summary |
|---|---|
public WorkbookEvaluator(EvaluationWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
| |
| WorkbookEvaluator | back to summary |
|---|---|
| pack-priv WorkbookEvaluator(EvaluationWorkbook workbook, IEvaluationListener evaluationListener, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) | |
| addExceptionInfo | back to summary |
|---|---|
| private NotImplementedException addExceptionInfo(NotImplementedException inner, int sheetIndex, int rowIndex, int columnIndex) Adds the current cell reference to the exception for easier debugging. Would be nice to get the formula text as well, but that seems to require too much digging around and casting to get the FormulaRenderingWorkbook. | |
| adjustRegionRelativeReference | back to summary |
|---|---|
| private boolean adjustRegionRelativeReference(Ptg[] ptgs, CellReference target, CellRangeAddressBase region) Adjust formula relative references by the offset between the start of the given region and the given target cell. That is, treat the region top-left cell as "A1" for the purposes of evaluating relative reference components (row and/or column), and further move references by the position of the target within the region.
| |
| attachToEnvironment | back to summary |
|---|---|
| pack-priv void attachToEnvironment(CollaboratingWorkbooksEnvironment collaboratingWorkbooksEnvironment, EvaluationCache cache, int workbookIx) | |
| clearAllCachedResultValues | back to summary |
|---|---|
| public void clearAllCachedResultValues() Should be called whenever there are changes to input cells in the evaluated workbook. Failure to call this method after changing cell values will cause incorrect behaviour of the evaluate~ methods of this class | |
| countTokensToBeSkipped | back to summary |
|---|---|
| private static int countTokensToBeSkipped(Ptg[] ptgs, int startIndex, int distInBytes) Calculates the number of tokens that the evaluator should skip upon reaching a tAttrSkip.
| |
| dereferenceResult | back to summary |
|---|---|
| private static ValueEval dereferenceResult(ValueEval evaluationResult, OperationEvaluationContext ec) Dereferences a single value from any AreaEval or RefEval evaluation result. If the supplied evaluationResult is just a plain value, it is returned as-is.
| |
| dereferenceResult | back to summary |
|---|---|
| public static ValueEval dereferenceResult(ValueEval evaluationResult, int srcRowNum, int srcColNum) Dereferences a single value from any AreaEval or RefEval evaluation result. If the supplied evaluationResult is just a plain value, it is returned as-is.
| |
| detachFromEnvironment | back to summary |
|---|---|
| pack-priv void detachFromEnvironment() Discards the current workbook environment and attaches to the default 'empty' environment. Also resets evaluation cache. | |
| evaluate | back to summary |
|---|---|
| public ValueEval evaluate(EvaluationCell srcCell) | |
| evaluate | back to summary |
|---|---|
| public ValueEval evaluate(String formula, CellReference ref) Evaluate a formula outside a cell value, e.g. conditional format rules or data validation expressions
| |
| evaluate | back to summary |
|---|---|
| public ValueEval evaluate(String formula, CellReference target, CellRangeAddressBase region) Some expressions need to be evaluated in terms of an offset from the top left corner of a region, such as some data validation and conditional format expressions, when those constraints apply to contiguous cells. When a relative formula is used, it must be evaluated by shifting by the target offset position relative to the top left of the range. Returns a single value e.g. a cell formula result or boolean value for conditional formatting.
| |
| evaluate | back to summary |
|---|---|
| private ValueEval evaluate(String formula, CellReference target, CellRangeAddressBase region, FormulaType formulaType) | |
| evaluateAny | back to summary |
|---|---|
| private ValueEval evaluateAny(EvaluationCell srcCell, int sheetIndex, int rowIndex, int columnIndex, EvaluationTracker tracker) | |
| evaluateFormula | back to summary |
|---|---|
pack-priv ValueEval evaluateFormula(OperationEvaluationContext ec, Ptg[] ptgs)
| |
| evaluateList | back to summary |
|---|---|
| public ValueEval evaluateList(String formula, CellReference target, CellRangeAddressBase region) Some expressions need to be evaluated in terms of an offset from the top left corner of a region, such as some data validation and conditional format expressions, when those constraints apply to contiguous cells. When a relative formula is used, it must be evaluated by shifting by the target offset position relative to the top left of the range. Returns a ValueEval that may be one or more values, such as the allowed values for a data validation constraint.
| |
| evaluateNameFormula | back to summary |
|---|---|
| pack-priv ValueEval evaluateNameFormula(Ptg[] ptgs, OperationEvaluationContext ec) YK: Used by OperationEvaluationContext to resolve indirect names. | |
| evaluateReference | back to summary |
|---|---|
| pack-priv ValueEval evaluateReference(EvaluationSheet sheet, int sheetIndex, int rowIndex, int columnIndex, EvaluationTracker tracker) Used by the lazy ref evals whenever they need to get the value of a contained cell. | |
| findUserDefinedFunction | back to summary |
|---|---|
| public FreeRefFunction findUserDefinedFunction(String functionName) | |
| getEnvironment | back to summary |
|---|---|
| pack-priv CollaboratingWorkbooksEnvironment getEnvironment() | |
| getEvalForNameRecord | back to summary |
|---|---|
| private ValueEval getEvalForNameRecord(EvaluationName nameRecord, OperationEvaluationContext ec) | |
| getEvalForPtg | back to summary |
|---|---|
| private ValueEval getEvalForPtg(Ptg ptg, OperationEvaluationContext ec) returns an appropriate Eval impl instance for the Ptg. The Ptg must be one of: Area3DPtg, AreaPtg, ReferencePtg, Ref3DPtg, IntPtg, NumberPtg, StringPtg, BoolPtg special Note: OperationPtg subtypes cannot be passed here! | |
| getEvaluationListener | back to summary |
|---|---|
| pack-priv IEvaluationListener getEvaluationListener() | |
| getName | back to summary |
|---|---|
| pack-priv EvaluationName getName(String name, int sheetIndex) | |
| getNotSupportedFunctionNames | back to summary |
|---|---|
| public static Collection Return a collection of functions that POI does not support
| |
| getOtherWorkbookEvaluator | back to summary |
|---|---|
pack-priv WorkbookEvaluator getOtherWorkbookEvaluator(String workbookName) throws WorkbookNotFoundException
| |
| getSheet | back to summary |
|---|---|
| pack-priv EvaluationSheet getSheet(int sheetIndex) | |
| getSheetIndex | back to summary |
|---|---|
| private int getSheetIndex(EvaluationSheet sheet) | |
| getSheetIndex | back to summary |
|---|---|
| pack-priv int getSheetIndex(String sheetName) Case-insensitive.
| |
| getSheetIndexByExternIndex | back to summary |
|---|---|
| pack-priv int getSheetIndexByExternIndex(int externSheetIndex) | |
| getSheetName | back to summary |
|---|---|
| pack-priv String getSheetName(int sheetIndex) also for debug use. Used in toString methods | |
| getSupportedFunctionNames | back to summary |
|---|---|
| public static Collection Return a collection of functions that POI can evaluate
| |
| getValueFromNonFormulaCell | back to summary |
|---|---|
| pack-priv static ValueEval getValueFromNonFormulaCell(EvaluationCell cell) Gets the value from a non-formula cell.
| |
| getWorkbook | back to summary |
|---|---|
| pack-priv EvaluationWorkbook getWorkbook() | |
| isDebugEvaluationOutputForNextEval | back to summary |
|---|---|
| public boolean isDebugEvaluationOutputForNextEval() | |
| isIgnoreMissingWorkbooks | back to summary |
|---|---|
| public boolean isIgnoreMissingWorkbooks() | |
| notifyDeleteCell | back to summary |
|---|---|
| public void notifyDeleteCell(EvaluationCell cell) Should be called to tell the cell value cache that the specified cell has just been deleted. | |
| notifyUpdateCell | back to summary |
|---|---|
| public void notifyUpdateCell(EvaluationCell cell) Should be called to tell the cell value cache that the specified (value or formula) cell has changed. | |
| processNameEval | back to summary |
|---|---|
| private ValueEval processNameEval(ValueEval eval, OperationEvaluationContext ec) | |
| registerFunction | back to summary |
|---|---|
| public static void registerFunction(String name, FreeRefFunction func) Register a ATP function in runtime.
| |
| registerFunction | back to summary |
|---|---|
| public static void registerFunction(String name, Function func) Register a function in runtime.
| |
| setDebugEvaluationOutputForNextEval | back to summary |
|---|---|
| public void setDebugEvaluationOutputForNextEval(boolean value) | |
| setIgnoreMissingWorkbooks | back to summary |
|---|---|
| public void setIgnoreMissingWorkbooks(boolean ignore) 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:
| |