You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/08/08 14:53:41 UTC
svn commit: r1892115 - in /poi/trunk/poi/src:
main/java/org/apache/poi/ss/formula/atp/XLookupFunction.java
test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java
Author: fanningpj
Date: Sun Aug 8 14:53:41 2021
New Revision: 1892115
URL: http://svn.apache.org/viewvc?rev=1892115&view=rev
Log:
init support for XLOOKUP
Modified:
poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/atp/XLookupFunction.java
poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/atp/XLookupFunction.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/atp/XLookupFunction.java?rev=1892115&r1=1892114&r2=1892115&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/atp/XLookupFunction.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/atp/XLookupFunction.java Sun Aug 8 14:53:41 2021
@@ -26,6 +26,9 @@ import java.util.Optional;
/**
* Implementation of Excel function XLOOKUP()
*
+ * POI does not currently support have return values with multiple columns and just takes the first cell
+ * right now.
+ *
* <b>Syntax</b><br>
* <b>XLOOKUP</b>(<b>lookup_value</b>, <b>lookup_array</b>, <b>return_array</b>, <b>[if_not_found]</b>, <b>[match_mode]</b>, <b>[search_mode]</b>)<p>
*
@@ -75,11 +78,9 @@ final class XLookupFunction implements F
if (matchedRow != -1) {
if (returnEval instanceof AreaEval) {
AreaEval area = (AreaEval)returnEval;
- if (area.getWidth() == 1) {
- return area.getRelativeValue(matchedRow, 0);
- } else {
- return area.getRow(matchedRow);
- }
+ //TODO to fully support XLOOKUP, we should return the full row
+ //but POI does not currently support functions returning multiple cell values
+ return area.getRelativeValue(matchedRow, 0);
}
}
if (notFound.isPresent()) {
Modified: poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java?rev=1892115&r1=1892114&r2=1892115&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java (original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java Sun Aug 8 14:53:41 2021
@@ -49,10 +49,7 @@ public class TestXLookupFunction {
try (HSSFWorkbook wb = initWorkbook2()) {
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
HSSFCell cell = wb.getSheetAt(0).getRow(0).createCell(100);
- cell.setCellFormula("XLOOKUP(B2,B5:B14,C5:D14)");
- fe.notifyUpdateCell(cell);
- CellValue result = fe.evaluate(cell);
- //TODO add assertions
+ assertString(fe, cell, "XLOOKUP(B2,B5:B14,C5:D14)", "Dianne Pugh");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org