Bug 57535 - Circular reference formulas cause "Unknown error type: -60" when querying error value
Summary: Circular reference formulas cause "Unknown error type: -60" when querying err...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.11-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-04 20:06 UTC by Martin Studer
Modified: 2016-05-13 14:41 UTC (History)
1 user (show)



Attachments
File to reproduce the issue (9.94 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2015-02-04 20:06 UTC, Martin Studer
Details

Note You need to log in before you can comment on or make changes to this bug.
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!