diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-03-07 13:15:01 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-03-07 13:15:01 +0000 |
commit | 19366d6013ce5e8a1db7de1af77a8a37580de194 (patch) | |
tree | 560c8f58864557d04376e472b55149c362c7d364 | |
parent | 3a496fded841b403138cec194280fc1f3ac43a66 (diff) | |
download | poi-19366d6013ce5e8a1db7de1af77a8a37580de194.tar.gz poi-19366d6013ce5e8a1db7de1af77a8a37580de194.zip |
[bug-65939] add partial fix for clearing formula with circular ref
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898681 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestFormulaEval.java | 22 | ||||
-rw-r--r-- | poi/src/test/java/org/apache/poi/ss/formula/TestFormulaEval.java | 22 |
2 files changed, 44 insertions, 0 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestFormulaEval.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestFormulaEval.java index 6d40f40f56..60e3f3144c 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestFormulaEval.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestFormulaEval.java @@ -25,4 +25,26 @@ class TestFormulaEval { assertEquals(CellType.ERROR, cell.getCellType()); } } + + @Test + void testCircularRef2() throws IOException { + try (XSSFWorkbook wb = new XSSFWorkbook()) { + XSSFSheet sheet = wb.createSheet(); + XSSFRow row = sheet.createRow(0); + XSSFCell cell0 = row.createCell(0); + XSSFCell cell1 = row.createCell(1); + cell0.setCellFormula("B1"); + cell1.setCellFormula("A1"); + XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); + formulaEvaluator.evaluateAll(); + + cell0.setCellFormula(null); + cell1.setCellFormula(null); + formulaEvaluator.notifyUpdateCell(cell0); + formulaEvaluator.notifyUpdateCell(cell1); + //the following asserts should probably be BLANK not ERROR + assertEquals(CellType.ERROR, cell0.getCellType()); + assertEquals(CellType.ERROR, cell1.getCellType()); + } + } } diff --git a/poi/src/test/java/org/apache/poi/ss/formula/TestFormulaEval.java b/poi/src/test/java/org/apache/poi/ss/formula/TestFormulaEval.java index 3f2a43d76e..3a507f57c1 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/TestFormulaEval.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/TestFormulaEval.java @@ -50,4 +50,26 @@ class TestFormulaEval { assertEquals(CellType.ERROR, cell.getCellType()); } } + + @Test + void testCircularRef2() throws IOException { + try (HSSFWorkbook wb = new HSSFWorkbook()) { + HSSFSheet sheet = wb.createSheet(); + HSSFRow row = sheet.createRow(0); + HSSFCell cell0 = row.createCell(0); + HSSFCell cell1 = row.createCell(1); + cell0.setCellFormula("B1"); + cell1.setCellFormula("A1"); + HSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); + formulaEvaluator.evaluateAll(); + + cell0.setCellFormula(null); + cell1.setCellFormula(null); + formulaEvaluator.notifyUpdateCell(cell0); + formulaEvaluator.notifyUpdateCell(cell1); + //the following asserts should probably be BLANK not ERROR + assertEquals(CellType.ERROR, cell0.getCellType()); + assertEquals(CellType.ERROR, cell1.getCellType()); + } + } } |