Summary: | Optional function arguments problems. | ||
---|---|---|---|
Product: | POI | Reporter: | Pavel Krupets <pkrupets> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | major | ||
Priority: | P2 | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Hardware: | Other | ||
OS: | Windows XP |
Description
Pavel Krupets
2007-09-11 09:15:01 UTC
Is this one still a problem, or has it been fixed by the formula parser updates? This does still happen, with r701302. Some earlier versions failed on parse-phase, thus "hiding" this bug. Easy to reproduce: Excel having "=IF(B1=1,5,)" in cell A1 Evaluate it: cell = sheet.getRow(0).getCell(0); if(cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA) { evaluator.evaluateFormulaCell(cell); } Get exception: java.util.EmptyStackException at java.util.Stack.peek(Stack.java:85) at java.util.Stack.pop(Stack.java:67) at org.apache.poi.ss.formula.WorkbookEvaluator.evaluateFormula(WorkbookEvaluator.java:300) at org.apache.poi.ss.formula.WorkbookEvaluator.internalEvaluate(WorkbookEvaluator.java:213) at org.apache.poi.ss.formula.WorkbookEvaluator.evaluate(WorkbookEvaluator.java:179) at org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateFormulaCellValue(HSSFFormulaEvaluator.java:272) at org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateFormulaCell(HSSFFormulaEvaluator.java:165) Fixed in svn r702231 You're right. POI was fixed a little while back to *parse* missing args properly, but the formula evaluator has never been capable of handling them. The new implementation assumes that missing arguments are equivalent to references to blank cells. The only example found (so far) that needed special attention was the count functions (COUNT and COUNTA) which really *do* count missing args (but not blank cells). |