Bug 57535

Summary: Circular reference formulas cause "Unknown error type: -60" when querying error value
Product: POI Reporter: Martin Studer <martin.studer>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: ramandeep21119
Priority: P2    
Version: 3.11-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: File to reproduce the issue

Description Martin Studer 2015-02-04 20:06:31 UTC
Created attachment 32432 [details]
File to reproduce the issue

See the attached Excel file minimal.xlsx where cells E4:E6 are involved in a circular reference.

The cell type for the evaluated cell E6 is CELL_TYPE_ERROR. Trying to query  the error value yields an IllegalArgumentException "Unknown error type: -60".

See the following code to reproduce the issue:

Workbook wb = WorkbookFactory.create(new File("minimal.xlsx"));
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
evaluator.clearAllCachedResultValues();
Sheet sheet = wb.getSheet("Sheet1");
Cell cell = sheet.getRow(5).getCell(4);
CellValue value = evaluator.evaluate(cell);
        
System.out.println(value.getCellType() == Cell.CELL_TYPE_ERROR); // true
CellUtils.getErrorMessage(value.getErrorValue()); // throws IllegalArgumentException: Unknown error type: -60
Comment 1 Nick Burch 2015-02-08 15:38:52 UTC
It seems we had two sets of error constants, one with a few more in than the other

As of r1658190, I've made FormulaError be the main one, deprecated the other, cleaned up ErrorEval to use only FormulaError, and added a unit test based on your code which now passes!