Class LookupUtils
- java.lang.Object
-
- org.apache.poi.ss.formula.functions.LookupUtils
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LookupUtils.CompareResult
Enumeration to support 4 valued comparison results.static interface
LookupUtils.LookupValueComparer
static class
LookupUtils.MatchMode
static class
LookupUtils.SearchMode
static interface
LookupUtils.ValueVector
Represents 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.ValueVector
createColumnVector(TwoDEval tableArray, int relativeColumnIndex)
static LookupUtils.ValueVector
createRowVector(TwoDEval tableArray, int relativeRowIndex)
static LookupUtils.ValueVector
createVector(RefEval re)
static LookupUtils.ValueVector
createVector(TwoDEval ae)
static int
lookupFirstIndexOfValue(ValueEval lookupValue, LookupUtils.ValueVector vector, boolean isRangeLookup)
static int
lookupIndexOfExactValue(ValueEval lookupValue, TwoDEval tableArray, int columnIndex)
static LookupUtils.MatchMode
matchMode(int m)
static boolean
resolveRangeLookupArg(ValueEval rangeLookupArg, int srcCellRow, int srcCellCol)
Resolves the last (optional) parameter (range_lookup) to the VLOOKUP and HLOOKUP functions.static int
resolveRowOrColIndexArg(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 TwoDEval
resolveTableArrayArg(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.SearchMode
searchMode(int s)
static int
xlookupIndexOfValue(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:
null
if 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
-
-