Author: fanningpj
Date: Mon Mar  7 13:15:01 2022
New Revision: 1898681

URL: http://svn.apache.org/viewvc?rev=1898681&view=rev
Log:
[bug-65939] add partial fix for clearing formula with circular ref

Modified:
    
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestFormulaEval.java
    poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/TestFormulaEval.java

Modified: 
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestFormulaEval.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestFormulaEval.java?rev=1898681&r1=1898680&r2=1898681&view=diff
==============================================================================
--- 
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestFormulaEval.java
 (original)
+++ 
poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestFormulaEval.java
 Mon Mar  7 13:15:01 2022
@@ -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());
+        }
+    }
 }

Modified: 
poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/TestFormulaEval.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/TestFormulaEval.java?rev=1898681&r1=1898680&r2=1898681&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/TestFormulaEval.java 
(original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/TestFormulaEval.java 
Mon Mar  7 13:15:01 2022
@@ -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());
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to