Class LookupUtils
java.lang.Object
org.apache.poi.ss.formula.functions.LookupUtils
Common functionality used by VLOOKUP, HLOOKUP, LOOKUP and MATCH
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classEnumeration to support 4 valued comparison results.static interfacestatic enumstatic enumstatic interfaceRepresents a single row or column within anAreaEval. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 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 TwoDEvalThe 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)
-
Constructor Details
-
LookupUtils
public LookupUtils()
-
-
Method Details
-
matchMode
-
searchMode
-
createRowVector
-
createColumnVector
public static LookupUtils.ValueVector createColumnVector(TwoDEval tableArray, int relativeColumnIndex) -
createVector
- Returns:
nullif the supplied area is neither a single row nor a single column
-
createVector
-
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
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
-