From 811d4faf7b060a07b2f842b834c82751cc859d37 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 6 Dec 2021 13:39:57 +0000 Subject: [PATCH] add broken test (xlookup) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895623 13f79535-47bb-0310-9956-ffa450edef68 --- .../ss/formula/atp/TestXLookupFunction.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java b/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java index 2ccc5ea410..ced480a227 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java @@ -142,6 +142,18 @@ public class TestXLookupFunction { } } + @Test + void testMicrosoftExample6() throws IOException { + try (HSSFWorkbook wb = initWorkbook6()) { + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); + HSSFCell cell = wb.getSheetAt(0).getRow(2).createCell(3); + assertDouble(fe, cell, "XLOOKUP(B3,B6:B10,E6:E10)", 75.28); + assertDouble(fe, cell, "XLOOKUP(C3,B6:B10,E6:E10)", 17.25); + //TODO next to fix FormulaParser to get this to work + //assertDouble(fe, cell, "SUM(XLOOKUP(B3,B6:B10,E6:E10):XLOOKUP(C3,B6:B10,E6:E10))", 110.70); + } + } + private HSSFWorkbook initWorkbook1() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(); @@ -240,4 +252,21 @@ public class TestXLookupFunction { return wb; } + private HSSFWorkbook initWorkbook6() { + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sheet = wb.createSheet(); + addRow(sheet, 0); + addRow(sheet, 1, null, "Start", "End", "Total"); + addRow(sheet, 2, null, "Grape", "Banana"); + addRow(sheet, 3, null, "United States", "US", "+1"); + addRow(sheet, 4); + addRow(sheet, 5, null, "Product", "Qty", "Price", "Total"); + addRow(sheet, 6, null, "Apple", 23, 0.52, 11.90); + addRow(sheet, 7, null, "Grape", 98, 0.77, 75.28); + addRow(sheet, 8, null, "Pear", 75, 0.24, 18.16); + addRow(sheet, 9, null, "Banana", 95, 0.18, 17.25); + addRow(sheet, 10, null, "Cherry", 42, 0.16, 6.80); + return wb; + } + } -- 2.39.5