diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-12-05 21:03:21 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-12-05 21:03:21 +0000 |
commit | 7e240d41f18322915629e1f1cf7b6d05bc9ac7b6 (patch) | |
tree | e72fe630ca8d6208daaa373c0f6a47ffbf6bebce /poi/src/main | |
parent | c390436c9a1821bb51d2dd125d4b521e06726606 (diff) | |
download | poi-7e240d41f18322915629e1f1cf7b6d05bc9ac7b6.tar.gz poi-7e240d41f18322915629e1f1cf7b6d05bc9ac7b6.zip |
initial work on example 5
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895603 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src/main')
-rw-r--r-- | poi/src/main/java/org/apache/poi/ss/formula/atp/XLookupFunction.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/atp/XLookupFunction.java b/poi/src/main/java/org/apache/poi/ss/formula/atp/XLookupFunction.java index fd27a8dc8a..5f9b1528db 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/atp/XLookupFunction.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/atp/XLookupFunction.java @@ -105,9 +105,15 @@ final class XLookupFunction implements FreeRefFunction, ArrayFunction { try { ValueEval lookupValue = OperandResolver.getSingleValue(lookupEval, srcRowIndex, srcColumnIndex); TwoDEval tableArray = LookupUtils.resolveTableArrayArg(indexEval); - int matchedRow; + LookupUtils.ValueVector vector; + if (tableArray.isColumn()) { + vector = LookupUtils.createColumnVector(tableArray, 0); + } else { + vector = LookupUtils.createRowVector(tableArray, 0); + } + int matchedIdx; try { - matchedRow = LookupUtils.xlookupIndexOfValue(lookupValue, LookupUtils.createColumnVector(tableArray, 0), matchMode, searchMode); + matchedIdx = LookupUtils.xlookupIndexOfValue(lookupValue, vector, matchMode, searchMode); } catch (EvaluationException e) { if (ErrorEval.NA.equals(e.getErrorEval())) { if (notFound != BlankEval.instance) { @@ -130,9 +136,17 @@ final class XLookupFunction implements FreeRefFunction, ArrayFunction { if (returnEval instanceof AreaEval) { AreaEval area = (AreaEval)returnEval; if (isSingleValue) { - return area.getRelativeValue(matchedRow, 0); + if (tableArray.isColumn()) { + return area.getRelativeValue(matchedIdx, 0); + } else { + return area.getRelativeValue(0, matchedIdx); + } + } + if (tableArray.isColumn()) { + return area.offset(matchedIdx, matchedIdx,0, area.getWidth() - 1); + } else { + return area.offset(0, area.getHeight() - 1,matchedIdx, matchedIdx); } - return area.offset(matchedRow, matchedRow,0, area.getWidth() - 1); } else { return returnEval; } |