Bug 58032 - Better handling of errors when evaluating formulas
Summary: Better handling of errors when evaluating formulas
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 5.2.2-FINAL
Hardware: All All
: P1 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL: In older Apache POI version 4.1.2, ce...
Depends on:
Reported: 2015-06-14 07:43 UTC by bardacp
Modified: 2022-09-22 21:36 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description bardacp 2015-06-14 07:43:09 UTC
When calling evaluate on cell with wrong formula e.g. CONCATENATE("a";) (which excel 2010 does not complain about) POI throws exception:

java.lang.IllegalArgumentException: Unexpected eval class (org.apache.poi.ss.formula.eval.MissingArgEval)

This exception has no information about row/cell.

It would be nice if thrown exception contained information about position(row, cell) of wrong formula.
Comment 1 Nick Burch 2015-06-14 12:15:08 UTC
Surely when you call FormulaEvaluator.evaluateFormulaCell(Cell), you have the Cell object to know what the co-ordinates of the problematic formula are?
Comment 2 bardacp 2015-06-14 14:06:41 UTC
Sure but first time I was using API I used https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/FormulaEvaluator.html#evaluateAll%28%29 where exception occured. From this exception I had no idea what was wrong, I had to debug POI classes to know what is wrong. If the text of exception was like "Wrong formula in cell BJ58" instead of "Unexpected eval class" it would save me a lot of time.

So method evaluateFormulaCell can be used if I want to know positions but I have to iterate sheets, cell, rows -> more code but still it throws "Unexpected eval class".
Comment 3 Archana Kumari 2022-09-08 05:36:40 UTC
In older Apache POI version 4.1.2, cell which is having error is highlighted with sheet name whereas in newer version 5.1.2 no error cell is highlighted