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 FreeRefFunction
UDF
-
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 CellReference
applyR1C1Reference(CellReference anchorReference, String relativeReference)
void
clearFunctionStack()
Clear function scope stack.void
clearOffsetRefPrecedent()
void
createOffsetRefPrecedent(ValueEval precedent)
void
enterFunction(int funcId)
Call when entering a function, used to examine current scope is in an aggregate function or not.FreeRefFunction
findUserDefinedFunction(String functionName)
ValueEval
getArea3DEval(Area3DPtg aptg)
ValueEval
getArea3DEval(Area3DPxg aptg)
ValueEval
getAreaEval(int firstRowIndex, int firstColumnIndex, int lastRowIndex, int lastColumnIndex, boolean row1Rel, boolean col1Rel, boolean row2Rel, boolean col2Rel)
ValueEval
getAreaValueEval(int firstRowIndex, int firstColumnIndex, int lastRowIndex, int lastColumnIndex, Object[][] tokens)
int
getColumnIndex()
static OperationEvaluationContext
getContext()
Object
getDependent()
ValueEval
getDynamicReference(String workbookName, String sheetName, String refStrPart1, String refStrPart2, boolean isA1Style)
Resolves a cell or area reference dynamically.EvaluationName
getName(String name, int contextSheetIndex)
ValueEval
getNameXEval(NameXPtg nameXPtg)
ValueEval
getNameXEval(NameXPxg nameXPxg)
int
getPtgIndex()
ValueEval
getRef3DEval(Ref3DPtg rptg)
ValueEval
getRef3DEval(Ref3DPxg rptg)
ValueEval
getRefEval(int rowIndex, int columnIndex, boolean rowRel, boolean colRel)
SheetRangeEvaluator
getRefEvaluatorForCurrentSheet()
int
getRowIndex()
int
getSheetIndex()
EvaluationWorkbook
getWorkbook()
WorkbookEvaluator
getWorkbookEvaluator()
boolean
isArraymode()
boolean
isArrayValue()
Returns current scope is need an array value.boolean
isEvalNameFormula()
Returns whether evaluating the DefinedName formula.boolean
isSingleValue()
default truevoid
leaveFunction()
Call when leaving a function, used for examine current scope is in an aggregate function or not.void
setArrayMode(boolean value)
static void
setContext(OperationEvaluationContext value)
void
setEvalNameFormula(boolean evalNameFormula)
Sets to indicate evaluating the DefinedName formula(evaluation result might be different from that of a cell formula) Default: falsevoid
setPtgIndex(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. Ifnull
the current workbook is assumed. Note - to evaluate formulas which use multiple workbooks, aCollaboratingWorkbooksEnvironment
must be set up.sheetName
- the name of the sheet containing the reference. May benull
(whenworkbookName
is 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 benull
isA1Style
- specifies the format forrefStrPart1
andrefStrPart2
. Passtrue
for 'A1' style andfalse
for 'R1C1' style.- Returns:
- a
RefEval
orAreaEval
- 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()
-
-