Package org.apache.poi.ss.formula
Class OperationEvaluationContext
- java.lang.Object
-
- org.apache.poi.ss.formula.OperationEvaluationContext
-
public final class OperationEvaluationContext extends Object
Contains all the contextual information required to evaluate an operation within a formulaFor POI internal use only
-
-
Field Summary
Fields Modifier and Type Field Description static FreeRefFunctionUDF
-
Constructor Summary
Constructors Constructor Description OperationEvaluationContext(WorkbookEvaluator bookEvaluator, EvaluationWorkbook workbook, int sheetIndex, int srcRowNum, int srcColNum, org.apache.poi.ss.formula.EvaluationTracker tracker, boolean isSingleValue, DependencyTracker dependencyTracker, Object ref, int[] offset)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CellReferenceapplyR1C1Reference(CellReference anchorReference, String relativeReference)voidclearFunctionStack()Clear function scope stack.voidclearOffsetRefPrecedent()voidcreateOffsetRefPrecedent(ValueEval precedent)voidenterFunction(int funcId)Call when entering a function, used to examine current scope is in an aggregate function or not.FreeRefFunctionfindUserDefinedFunction(String functionName)ValueEvalgetArea3DEval(Area3DPtg aptg)ValueEvalgetArea3DEval(Area3DPxg aptg)ValueEvalgetAreaEval(int firstRowIndex, int firstColumnIndex, int lastRowIndex, int lastColumnIndex, boolean row1Rel, boolean col1Rel, boolean row2Rel, boolean col2Rel)ValueEvalgetAreaValueEval(int firstRowIndex, int firstColumnIndex, int lastRowIndex, int lastColumnIndex, Object[][] tokens)intgetColumnIndex()static OperationEvaluationContextgetContext()ObjectgetDependent()ValueEvalgetDynamicReference(String workbookName, String sheetName, String refStrPart1, String refStrPart2, boolean isA1Style)Resolves a cell or area reference dynamically.EvaluationNamegetName(String name, int contextSheetIndex)ValueEvalgetNameXEval(NameXPtg nameXPtg)ValueEvalgetNameXEval(NameXPxg nameXPxg)intgetPtgIndex()ValueEvalgetRef3DEval(Ref3DPtg rptg)ValueEvalgetRef3DEval(Ref3DPxg rptg)ValueEvalgetRefEval(int rowIndex, int columnIndex, boolean rowRel, boolean colRel)SheetRangeEvaluatorgetRefEvaluatorForCurrentSheet()intgetRowIndex()intgetSheetIndex()EvaluationWorkbookgetWorkbook()WorkbookEvaluatorgetWorkbookEvaluator()booleanisArraymode()booleanisArrayValue()Returns current scope is need an array value.booleanisEvalNameFormula()Returns whether evaluating the DefinedName formula.booleanisSingleValue()default truevoidleaveFunction()Call when leaving a function, used for examine current scope is in an aggregate function or not.voidsetArrayMode(boolean value)static voidsetContext(OperationEvaluationContext value)voidsetEvalNameFormula(boolean evalNameFormula)Sets to indicate evaluating the DefinedName formula(evaluation result might be different from that of a cell formula) Default: falsevoidsetPtgIndex(int index)
-
-
-
Field Detail
-
UDF
public static final FreeRefFunction UDF
-
-
Constructor Detail
-
OperationEvaluationContext
public OperationEvaluationContext(WorkbookEvaluator bookEvaluator, EvaluationWorkbook workbook, int sheetIndex, int srcRowNum, int srcColNum, org.apache.poi.ss.formula.EvaluationTracker tracker, boolean isSingleValue, DependencyTracker dependencyTracker, Object ref, int[] offset)
-
-
Method Detail
-
enterFunction
public void enterFunction(int funcId)
Call when entering a function, used to examine current scope is in an aggregate function or not.- Parameters:
funcId- the function id- Since:
- 5.8.0
-
leaveFunction
public void leaveFunction()
Call when leaving a function, used for examine current scope is in an aggregate function or not.- Since:
- 5.8.0
-
isArrayValue
public boolean isArrayValue()
Returns current scope is need an array value.- Since:
- 5.8.0
-
clearFunctionStack
public void clearFunctionStack()
Clear function scope stack.- Since:
- 5.8.0
-
isArraymode
public boolean isArraymode()
-
setArrayMode
public void setArrayMode(boolean value)
-
getWorkbook
public EvaluationWorkbook getWorkbook()
-
getRowIndex
public int getRowIndex()
-
getColumnIndex
public int getColumnIndex()
-
getRefEvaluatorForCurrentSheet
public SheetRangeEvaluator getRefEvaluatorForCurrentSheet()
-
getDynamicReference
public ValueEval getDynamicReference(String workbookName, String sheetName, String refStrPart1, String refStrPart2, boolean isA1Style)
Resolves a cell or area reference dynamically.- Parameters:
workbookName- the name of the workbook containing the reference. Ifnullthe current workbook is assumed. Note - to evaluate formulas which use multiple workbooks, aCollaboratingWorkbooksEnvironmentmust be set up.sheetName- the name of the sheet containing the reference. May benull(whenworkbookNameis also null) in which case the current workbook and sheet is assumed.refStrPart1- the single cell reference or first part of the area reference. Must not benull.refStrPart2- the second part of the area reference. For single cell references this parameter must benullisA1Style- specifies the format forrefStrPart1andrefStrPart2. Passtruefor 'A1' style andfalsefor 'R1C1' style.- Returns:
- a
RefEvalorAreaEval - Throws:
IllegalStateException- If invalid parameters are provided
-
clearOffsetRefPrecedent
public void clearOffsetRefPrecedent()
-
createOffsetRefPrecedent
public void createOffsetRefPrecedent(ValueEval precedent)
-
findUserDefinedFunction
public FreeRefFunction findUserDefinedFunction(String functionName)
-
getRefEval
public ValueEval getRefEval(int rowIndex, int columnIndex, boolean rowRel, boolean colRel)
-
getAreaEval
public ValueEval getAreaEval(int firstRowIndex, int firstColumnIndex, int lastRowIndex, int lastColumnIndex, boolean row1Rel, boolean col1Rel, boolean row2Rel, boolean col2Rel)
-
getWorkbookEvaluator
public WorkbookEvaluator getWorkbookEvaluator()
-
getAreaValueEval
public ValueEval getAreaValueEval(int firstRowIndex, int firstColumnIndex, int lastRowIndex, int lastColumnIndex, Object[][] tokens)
-
getSheetIndex
public int getSheetIndex()
-
isSingleValue
public boolean isSingleValue()
default true- Returns:
- flag indicating whether evaluation should "unwrap" the result to a single value based on the context row/column
-
applyR1C1Reference
public static CellReference applyR1C1Reference(CellReference anchorReference, String relativeReference)
-
getPtgIndex
public int getPtgIndex()
-
setPtgIndex
public void setPtgIndex(int index)
-
getName
public EvaluationName getName(String name, int contextSheetIndex)
-
getDependent
public Object getDependent()
-
setEvalNameFormula
public void setEvalNameFormula(boolean evalNameFormula)
Sets to indicate evaluating the DefinedName formula(evaluation result might be different from that of a cell formula) Default: false- Parameters:
evalNameFormula-- Since:
- 5.7.0
-
isEvalNameFormula
public boolean isEvalNameFormula()
Returns whether evaluating the DefinedName formula.- Returns:
- Since:
- 5.7.0
-
setContext
public static void setContext(OperationEvaluationContext value)
-
getContext
public static OperationEvaluationContext getContext()
-
-