|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.poi.ss.formula.WorkbookEvaluator
@Internal public final class WorkbookEvaluator
Evaluates formula cells.
For performance reasons, this class keeps a cache of all previously calculated intermediate cell values. Be sure to callclearAllCachedResultValues()
if any workbook cells are changed between
calls to evaluate~ methods on this class.
Constructor Summary | |
---|---|
WorkbookEvaluator(EvaluationWorkbook workbook,
IStabilityClassifier stabilityClassifier,
UDFFinder udfFinder)
|
Method Summary | |
---|---|
protected 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. |
protected boolean |
adjustRegionRelativeReference(Ptg[] ptgs,
int deltaRow,
int deltaColumn)
Adjust the formula relative cell references by a given delta |
void |
clearAllCachedResultValues()
Should be called whenever there are changes to input cells in the evaluated workbook. |
static ValueEval |
dereferenceResult(ValueEval evaluationResult,
int srcRowNum,
int srcColNum)
Dereferences a single value from any AreaEval or RefEval evaluation result. |
ValueEval |
evaluate(EvaluationCell srcCell)
|
ValueEval |
evaluate(java.lang.String formula,
CellReference ref)
Evaluate a formula outside a cell value, e.g. |
ValueEval |
evaluate(java.lang.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. |
ValueEval |
evaluateList(java.lang.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. |
FreeRefFunction |
findUserDefinedFunction(java.lang.String functionName)
|
static java.util.Collection<java.lang.String> |
getNotSupportedFunctionNames()
Return a collection of functions that POI does not support |
static java.util.Collection<java.lang.String> |
getSupportedFunctionNames()
Return a collection of functions that POI can evaluate |
boolean |
isDebugEvaluationOutputForNextEval()
|
boolean |
isIgnoreMissingWorkbooks()
|
void |
notifyDeleteCell(EvaluationCell cell)
Should be called to tell the cell value cache that the specified cell has just been deleted. |
void |
notifyUpdateCell(EvaluationCell cell)
Should be called to tell the cell value cache that the specified (value or formula) cell has changed. |
static void |
registerFunction(java.lang.String name,
FreeRefFunction func)
Register a ATP function in runtime. |
static void |
registerFunction(java.lang.String name,
Function func)
Register a function in runtime. |
void |
setDebugEvaluationOutputForNextEval(boolean value)
|
void |
setIgnoreMissingWorkbooks(boolean ignore)
Whether to ignore missing references to external workbooks and use cached formula results in the main workbook instead. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WorkbookEvaluator(EvaluationWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
udfFinder
- pass null
for default (AnalysisToolPak only)Method Detail |
---|
public void clearAllCachedResultValues()
public void notifyUpdateCell(EvaluationCell cell)
public void notifyDeleteCell(EvaluationCell cell)
public ValueEval evaluate(EvaluationCell srcCell)
public static ValueEval dereferenceResult(ValueEval evaluationResult, int srcRowNum, int srcColNum)
NumberEval
, StringEval
, BoolEval
, or
ErrorEval
. Never null
. BlankEval
is
converted to NumberEval.ZERO
public FreeRefFunction findUserDefinedFunction(java.lang.String functionName)
public ValueEval evaluate(java.lang.String formula, CellReference ref)
formula
- to evaluateref
- defines the optional sheet and row/column base for the formula, if it is relative
public ValueEval evaluate(java.lang.String formula, CellReference target, CellRangeAddressBase region)
Returns a single value e.g. a cell formula result or boolean value for conditional formatting.
formula
- target
- cell context for the operationregion
- containing the cell
java.lang.IllegalArgumentException
- if target does not define a sheet name to evaluate the formula on.public ValueEval evaluateList(java.lang.String formula, CellReference target, CellRangeAddressBase region)
Returns a ValueEval that may be one or more values, such as the allowed values for a data validation constraint.
formula
- target
- cell context for the operationregion
- containing the cell
java.lang.IllegalArgumentException
- if target does not define a sheet name to evaluate the formula on.protected boolean adjustRegionRelativeReference(Ptg[] ptgs, CellReference target, CellRangeAddressBase region)
ptgs
- target
- cell within the region to use.region
- containing the cell
java.lang.IndexOutOfBoundsException
- if the resulting shifted row/column indexes are over the document format limits
java.lang.IllegalArgumentException
- if target is not within region.protected boolean adjustRegionRelativeReference(Ptg[] ptgs, int deltaRow, int deltaColumn)
ptgs
- deltaRow
- target row offset from the top left cell of a regiondeltaColumn
- target column offset from the top left cell of a region
java.lang.IndexOutOfBoundsException
- if the resulting shifted row/column indexes are over the document format limits
java.lang.IllegalArgumentException
- if either of the deltas are negative, as the assumption is we are shifting formulas
relative to the top left cell of a region.public void setIgnoreMissingWorkbooks(boolean ignore)
In some cases exetrnal workbooks referenced by formulas in the main workbook are not avaiable. With this method you can control how POI handles such missing references:
CollaboratingWorkbooksEnvironment.WorkbookNotFoundException
if an external reference cannot be resolved
ignore
- whether to ignore missing references to external workbookspublic boolean isIgnoreMissingWorkbooks()
public static java.util.Collection<java.lang.String> getSupportedFunctionNames()
public static java.util.Collection<java.lang.String> getNotSupportedFunctionNames()
public static void registerFunction(java.lang.String name, FreeRefFunction func)
name
- the function namefunc
- the functoin to register
java.lang.IllegalArgumentException
- if the function is unknown or already registered.public static void registerFunction(java.lang.String name, Function func)
name
- the function namefunc
- the functoin to register
java.lang.IllegalArgumentException
- if the function is unknown or already registered.public void setDebugEvaluationOutputForNextEval(boolean value)
public boolean isDebugEvaluationOutputForNextEval()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |