aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-07-30 19:29:34 +0000
committerPJ Fanning <fanningpj@apache.org>2021-07-30 19:29:34 +0000
commitf4cf7dc99e38e1faf4f6af960daf281fccf65b35 (patch)
treecc35408c1551b73b5356db8ca6e1452086409dd8
parentd8d60e4e72c29f787fb508bd6d759d18d4b35dba (diff)
downloadpoi-f4cf7dc99e38e1faf4f6af960daf281fccf65b35.tar.gz
poi-f4cf7dc99e38e1faf4f6af960daf281fccf65b35.zip
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
-rw-r--r--poi/src/test/java/org/apache/poi/ss/formula/functions/TestSumifs.java17
1 files changed, 17 insertions, 0 deletions
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;
+ }
}