Class LookupUtils
- java.lang.Object
-
- org.apache.poi.ss.formula.functions.LookupUtils
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLookupUtils.CompareResultEnumeration to support 4 valued comparison results.static interfaceLookupUtils.LookupValueComparerstatic classLookupUtils.MatchModestatic classLookupUtils.SearchModestatic interfaceLookupUtils.ValueVectorRepresents a single row or column within anAreaEval.
-
Constructor Summary
Constructors Constructor Description LookupUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static LookupUtils.ValueVectorcreateColumnVector(TwoDEval tableArray, int relativeColumnIndex)static LookupUtils.ValueVectorcreateRowVector(TwoDEval tableArray, int relativeRowIndex)static LookupUtils.ValueVectorcreateVector(RefEval re)static LookupUtils.ValueVectorcreateVector(TwoDEval ae)static intlookupFirstIndexOfValue(ValueEval lookupValue, LookupUtils.ValueVector vector, boolean isRangeLookup)static intlookupIndexOfExactValue(ValueEval lookupValue, TwoDEval tableArray, int columnIndex)static LookupUtils.MatchModematchMode(int m)static booleanresolveRangeLookupArg(ValueEval rangeLookupArg, int srcCellRow, int srcCellCol)Resolves the last (optional) parameter (range_lookup) to the VLOOKUP and HLOOKUP functions.static intresolveRowOrColIndexArg(ValueEval rowColIndexArg, int srcCellRow, int srcCellCol)Processes the third argument to VLOOKUP, or HLOOKUP (col_index_num or row_index_num respectively).
Sample behaviour: Sample behaviour Input ReturnValue Thrown Error 54 2.92 "5"4 "2.18e1"21 "-$2"-3* FALSE-1* TRUE0 "TRUE" #REF! "abc" #REF! "" #REF! <blank> #VALUE!
Note - out of range errors (result index too high) are handled by the caller.static TwoDEvalresolveTableArrayArg(ValueEval eval)The second argument (table_array) should be an area ref, but can actually be a cell ref, in which case it is interpreted as a 1x1 area ref.static LookupUtils.SearchModesearchMode(int s)static intxlookupIndexOfValue(ValueEval lookupValue, LookupUtils.ValueVector vector, LookupUtils.MatchMode matchMode, LookupUtils.SearchMode searchMode)
-
-
-
Method Detail
-
matchMode
public static LookupUtils.MatchMode matchMode(int m)
-
searchMode
public static LookupUtils.SearchMode searchMode(int s)
-
createRowVector
public static LookupUtils.ValueVector createRowVector(TwoDEval tableArray, int relativeRowIndex)
-
createColumnVector
public static LookupUtils.ValueVector createColumnVector(TwoDEval tableArray, int relativeColumnIndex)
-
createVector
public static LookupUtils.ValueVector createVector(TwoDEval ae)
- Returns:
nullif the supplied area is neither a single row nor a single column
-
createVector
public static LookupUtils.ValueVector createVector(RefEval re)
-
resolveRowOrColIndexArg
public static int resolveRowOrColIndexArg(ValueEval rowColIndexArg, int srcCellRow, int srcCellCol) throws EvaluationException
Processes the third argument to VLOOKUP, or HLOOKUP (col_index_num or row_index_num respectively).
Sample behaviour:Sample behaviour Input Return Value Thrown Error 5 4 2.9 2 "5" 4 "2.18e1" 21 "-$2" -3 * FALSE -1 * TRUE 0 "TRUE" #REF! "abc" #REF! "" #REF! <blank> #VALUE!
Note - out of range errors (result index too high) are handled by the caller.- Returns:
- column or row index as a zero-based value, never negative.
- Throws:
EvaluationException- when the specified arg cannot be coerced to a non-negative integer
-
resolveTableArrayArg
public static TwoDEval resolveTableArrayArg(ValueEval eval) throws EvaluationException
The second argument (table_array) should be an area ref, but can actually be a cell ref, in which case it is interpreted as a 1x1 area ref. Other scalar values cause #VALUE! error.- Throws:
EvaluationException
-
resolveRangeLookupArg
public static boolean resolveRangeLookupArg(ValueEval rangeLookupArg, int srcCellRow, int srcCellCol) throws EvaluationException
Resolves the last (optional) parameter (range_lookup) to the VLOOKUP and HLOOKUP functions.- Parameters:
rangeLookupArg- must not benull- Throws:
EvaluationException
-
lookupFirstIndexOfValue
public static int lookupFirstIndexOfValue(ValueEval lookupValue, LookupUtils.ValueVector vector, boolean isRangeLookup) throws EvaluationException
- Throws:
EvaluationException
-
xlookupIndexOfValue
public static int xlookupIndexOfValue(ValueEval lookupValue, LookupUtils.ValueVector vector, LookupUtils.MatchMode matchMode, LookupUtils.SearchMode searchMode) throws EvaluationException
- Throws:
EvaluationException
-
lookupIndexOfExactValue
public static int lookupIndexOfExactValue(ValueEval lookupValue, TwoDEval tableArray, int columnIndex) throws EvaluationException
- Throws:
EvaluationException
-
-