From: PJ Fanning Date: Sat, 7 Aug 2021 10:45:18 +0000 (+0000) Subject: fix TextJoin use case that was not handled X-Git-Tag: REL_5_1_0~75 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d475e00f3a4c09546ec8c5ed49d456225cc78a43;p=poi.git fix TextJoin use case that was not handled git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892065 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi/src/test/java/org/apache/poi/ss/formula/atp/TestTextJoinFunction.java b/poi/src/test/java/org/apache/poi/ss/formula/atp/TestTextJoinFunction.java index 00792985ac..29d716bcec 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/atp/TestTextJoinFunction.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/atp/TestTextJoinFunction.java @@ -182,6 +182,18 @@ public class TestTextJoinFunction { } } + @Test + void testMicrosoftExample2() throws IOException { + try (HSSFWorkbook wb = initWorkbook2()) { + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); + HSSFCell cell = wb.getSheetAt(0).getRow(0).createCell(100); + confirmResult(fe, cell, "TEXTJOIN(\", \", TRUE, A2:B8)", + "a1, b1, a2, b2, a4, b4, a5, b5, a6, b6, a7, b7"); + confirmResult(fe, cell, "TEXTJOIN(\", \", FALSE, A2:B8)", + "a1, b1, a2, b2, , , a4, b4, a5, b5, a6, b6, a7, b7"); + } + } + private HSSFWorkbook initWorkbook1() { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(); @@ -196,6 +208,18 @@ public class TestTextJoinFunction { return wb; } + private HSSFWorkbook initWorkbook2() { + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sheet = wb.createSheet(); + addRow(sheet, 0, "A’s", "B’s"); + for (int i = 1; i <= 7; i++) { + if (i != 3) { + addRow(sheet, i, "a" + i, "b" + i); + } + } + return wb; + } + private static void confirmResult(HSSFFormulaEvaluator fe, HSSFCell cell, String formulaText, String expectedResult) { cell.setCellFormula(formulaText); fe.notifyUpdateCell(cell);