]> source.dussan.org Git - poi.git/commitdiff
Add test which verifies that bug 61652 is not appearing any more on latest trunk
authorDominik Stadler <centic@apache.org>
Mon, 1 Jan 2018 14:39:08 +0000 (14:39 +0000)
committerDominik Stadler <centic@apache.org>
Mon, 1 Jan 2018 14:39:08 +0000 (14:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1819769 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
test-data/spreadsheet/61652.xlsx [new file with mode: 0644]

index 106dceb494350c59efa151781d91bac01e11ad34..f5a51c100be1029ef82211b894d9e0cc6e1efa44 100644 (file)
@@ -65,11 +65,14 @@ import org.apache.poi.openxml4j.util.ZipSecureFile;
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.ss.SpreadsheetVersion;
+import org.apache.poi.ss.formula.ConditionalFormattingEvaluator;
+import org.apache.poi.ss.formula.EvaluationConditionalFormatRule;
 import org.apache.poi.ss.formula.FormulaParser;
 import org.apache.poi.ss.formula.FormulaRenderer;
 import org.apache.poi.ss.formula.FormulaShifter;
 import org.apache.poi.ss.formula.FormulaType;
 import org.apache.poi.ss.formula.WorkbookEvaluator;
+import org.apache.poi.ss.formula.WorkbookEvaluatorProvider;
 import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.formula.eval.NumberEval;
 import org.apache.poi.ss.formula.functions.Function;
@@ -3209,4 +3212,23 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
             assertEquals(1, cellValue.getNumberValue(), 0.0001);
         }
     }
+
+    @Test
+    public void test61652() throws IOException {
+        try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("61652.xlsx")) {
+            Sheet sheet = wb.getSheet("IRPPCalc");
+            Row row = sheet.getRow(11);
+            Cell cell = row.getCell(18);
+            WorkbookEvaluatorProvider fe = (WorkbookEvaluatorProvider) wb.getCreationHelper().createFormulaEvaluator();
+            ConditionalFormattingEvaluator condfmt = new ConditionalFormattingEvaluator(wb, fe);
+
+            assertEquals("Conditional formatting is not triggered for this cell",
+                    "[]", condfmt.getConditionalFormattingForCell(cell).toString());
+
+            // but we can read the conditional formatting itself
+            List<EvaluationConditionalFormatRule> rules = condfmt.getFormatRulesForSheet(sheet);
+            assertEquals(1, rules.size());
+            assertEquals("AND($A1>=EDATE($D$6,3),$B1>0)", rules.get(0).getFormula1());
+        }
+    }
 }
diff --git a/test-data/spreadsheet/61652.xlsx b/test-data/spreadsheet/61652.xlsx
new file mode 100644 (file)
index 0000000..024d377
Binary files /dev/null and b/test-data/spreadsheet/61652.xlsx differ