]> source.dussan.org Git - poi.git/commitdiff
SUMIFS should sum and treat booleans and strings as zero
authorPJ Fanning <fanningpj@apache.org>
Fri, 30 Jul 2021 19:29:34 +0000 (19:29 +0000)
committerPJ Fanning <fanningpj@apache.org>
Fri, 30 Jul 2021 19:29:34 +0000 (19:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891905 13f79535-47bb-0310-9956-ffa450edef68

poi/src/test/java/org/apache/poi/ss/formula/functions/TestSumifs.java

index 234d6392f44a5b69fae967340dbc6d0ac48a593e..58d04912fef6064cc1c57653c99293e4f59b50d7 100644 (file)
@@ -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;
+    }
 }