Author: fanningpj
Date: Mon Mar 7 13:11:23 2022
New Revision: 1898680
URL: http://svn.apache.org/viewvc?rev=1898680&view=rev
Log:
[bug-65939] add partial fix for clearing formula with circular ref
Modified:
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java
poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/TestFormulaEval.java
Modified:
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java?rev=1898680&r1=1898679&r2=1898680&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java
(original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java Mon
Mar 7 13:11:23 2022
@@ -604,7 +604,11 @@ public class HSSFCell extends CellBase {
case ERROR:
byte errorValue = (byte)
((FormulaRecordAggregate)_record).getFormulaRecord().getCachedErrorValue();
_record = new BoolErrRecord();
- ((BoolErrRecord)_record).setValue(errorValue);
+ try {
+ ((BoolErrRecord)_record).setValue(errorValue);
+ } catch (IllegalArgumentException ise) {
+ ((BoolErrRecord)_record).setValue((byte)
ErrorEval.REF_INVALID.getErrorCode());
+ }
_cellType = CellType.ERROR;
break;
default:
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=1898680&r1=1898679&r2=1898680&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:11:23 2022
@@ -25,7 +25,6 @@ import org.apache.poi.hssf.usermodel.HSS
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.CellType;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@@ -34,7 +33,6 @@ import static org.junit.jupiter.api.Asse
class TestFormulaEval {
- @Disabled("https://bz.apache.org/bugzilla/show_bug.cgi?id=65939")
@Test
void testCircularRef() throws IOException {
try (HSSFWorkbook wb = new HSSFWorkbook()) {
@@ -46,8 +44,10 @@ class TestFormulaEval {
// the following assert should probably be NUMERIC not ERROR (from
testing in Excel itself)
assertEquals(CellType.ERROR,
formulaEvaluator.evaluateFormulaCell(cell));
- cell.setCellFormula(null); //this line fails
+ cell.setCellFormula(null);
formulaEvaluator.notifyUpdateCell(cell);
+ //the following assert should probably be BLANK not ERROR
+ assertEquals(CellType.ERROR, cell.getCellType());
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]