From f4cf7dc99e38e1faf4f6af960daf281fccf65b35 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 30 Jul 2021 19:29:34 +0000 Subject: [PATCH] SUMIFS should sum and treat booleans and strings as zero git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891905 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ss/formula/functions/TestSumifs.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSumifs.java b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSumifs.java index 234d6392f4..58d04912fe 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSumifs.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSumifs.java @@ -382,6 +382,15 @@ final class TestSumifs { } } + @Test + void testMicrosoftExample1WithBooleanAndString() throws IOException { + try (HSSFWorkbook wb = initWorkbook1()) { + HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); + HSSFCell cell = wb.getSheetAt(0).getRow(0).createCell(100); + assertDouble(fe, cell, "SUMIFS(A2:A11, B2:B11, \"<>Bananas\", C2:C11, \"Tom\")", 30); + } + } + //see https://support.microsoft.com/en-us/office/sumifs-function-c9e748f5-7ea7-455d-9406-611cebce642b private HSSFWorkbook initWorkbook1() { HSSFWorkbook wb = new HSSFWorkbook(); @@ -404,4 +413,12 @@ final class TestSumifs { addRow(sheet, 9, FormulaError.NA, "Pears", "Tom"); return wb; } + + private HSSFWorkbook initWorkbook1WithBooleanAnString() { + HSSFWorkbook wb = initWorkbook1(); + HSSFSheet sheet = wb.getSheetAt(0); + addRow(sheet, 9, true, "Pears", "Tom"); + addRow(sheet, 10, "abc", "Kumquats", "Tom"); + return wb; + } }