org.apache.poi.ss.formula
Class WorkbookEvaluator
- java.lang.Object
-
- org.apache.poi.ss.formula.WorkbookEvaluator
-
public final class WorkbookEvaluator extends java.lang.ObjectEvaluates 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.
For POI internal use only
-
-
Constructor Summary
Constructors Constructor and Description WorkbookEvaluator(EvaluationWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclearAllCachedResultValues()Should be called whenever there are changes to input cells in the evaluated workbook.static ValueEvaldereferenceResult(ValueEval evaluationResult, int srcRowNum, int srcColNum)Dereferences a single value from any AreaEval or RefEval evaluation result.ValueEvalevaluate(EvaluationCell srcCell)FreeRefFunctionfindUserDefinedFunction(java.lang.String functionName)static java.util.Collection<java.lang.String>getNotSupportedFunctionNames()Return a collection of functions that POI does not supportstatic java.util.Collection<java.lang.String>getSupportedFunctionNames()Return a collection of functions that POI can evaluatevoidnotifyDeleteCell(EvaluationCell cell)Should be called to tell the cell value cache that the specified cell has just been deleted.voidnotifyUpdateCell(EvaluationCell cell)Should be called to tell the cell value cache that the specified (value or formula) cell has changed.static voidregisterFunction(java.lang.String name, FreeRefFunction func)Register a ATP function in runtime.static voidregisterFunction(java.lang.String name, Function func)Register a function in runtime.voidsetDebugEvaluationOutputForNextEval(boolean value)voidsetIgnoreMissingWorkbooks(boolean ignore)Whether to ignore missing references to external workbooks and use cached formula results in the main workbook instead.
-
-
-
Constructor Detail
-
WorkbookEvaluator
public WorkbookEvaluator(EvaluationWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder)
- Parameters:
udfFinder- passnullfor default (AnalysisToolPak only)
-
-
Method Detail
-
clearAllCachedResultValues
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
-
notifyUpdateCell
public void notifyUpdateCell(EvaluationCell cell)
Should be called to tell the cell value cache that the specified (value or formula) cell has changed.
-
notifyDeleteCell
public void notifyDeleteCell(EvaluationCell cell)
Should be called to tell the cell value cache that the specified cell has just been deleted.
-
evaluate
public ValueEval evaluate(EvaluationCell srcCell)
-
dereferenceResult
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.- Returns:
- a
NumberEval,StringEval,BoolEval, orErrorEval. Nevernull.BlankEvalis converted toNumberEval.ZERO
-
findUserDefinedFunction
public FreeRefFunction findUserDefinedFunction(java.lang.String functionName)
-
setIgnoreMissingWorkbooks
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 exetrnal workbooks referenced by formulas in the main workbook are not avaiable. With this method you can control how POI handles such missing references:
- by default ignoreMissingWorkbooks=false and POI throws
CollaboratingWorkbooksEnvironment.WorkbookNotFoundExceptionif an external reference cannot be resolved - if ignoreMissingWorkbooks=true then POI uses cached formula result that already exists in the main workbook
- Parameters:
ignore- whether to ignore missing references to external workbooks- See Also:
- Bug 52575 for details
- by default ignoreMissingWorkbooks=false and POI throws
-
getSupportedFunctionNames
public static java.util.Collection<java.lang.String> getSupportedFunctionNames()
Return a collection of functions that POI can evaluate- Returns:
- names of functions supported by POI
-
getNotSupportedFunctionNames
public static java.util.Collection<java.lang.String> getNotSupportedFunctionNames()
Return a collection of functions that POI does not support- Returns:
- names of functions NOT supported by POI
-
registerFunction
public static void registerFunction(java.lang.String name, FreeRefFunction func)Register a ATP function in runtime.- Parameters:
name- the function namefunc- the functoin to register- Throws:
java.lang.IllegalArgumentException- if the function is unknown or already registered.- Since:
- 3.8 beta6
-
registerFunction
public static void registerFunction(java.lang.String name, Function func)Register a function in runtime.- Parameters:
name- the function namefunc- the functoin to register- Throws:
java.lang.IllegalArgumentException- if the function is unknown or already registered.- Since:
- 3.8 beta6
-
setDebugEvaluationOutputForNextEval
public void setDebugEvaluationOutputForNextEval(boolean value)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG