poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 56688] New: EDate formula throws an exception for named argument
Date Tue, 01 Jul 2014 11:38:14 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=56688

            Bug ID: 56688
           Summary: EDate formula throws an exception for named argument
           Product: POI
           Version: 3.10
          Hardware: Macintosh
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
          Assignee: dev@poi.apache.org
          Reporter: kirill.frolov77@gmail.com

It is obviously missing check for named reference before cast in EDate.java.


Here is the stacktrace

Caused by: java.lang.ClassCastException: org.apache.poi.ss.formula.LazyRefEval
cannot be cast to org.apache.poi.ss.formula.eval.NumberEval
    at org.apache.poi.ss.formula.functions.EDate.evaluate(EDate.java:39)
    at
org.apache.poi.ss.formula.UserDefinedFunction.evaluate(UserDefinedFunction.java:64)
    at
org.apache.poi.ss.formula.OperationEvaluatorFactory.evaluate(OperationEvaluatorFactory.java:129)
    at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluateFormula(WorkbookEvaluator.java:525)
    at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluateAny(WorkbookEvaluator.java:288)
    at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluate(WorkbookEvaluator.java:230)
    at
org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.evaluateFormulaCellValue(XSSFFormulaEvaluator.java:264)
    at
org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.evaluateFormulaCell(XSSFFormulaEvaluator.java:151)
    at
org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateAllFormulaCells(HSSFFormulaEvaluator.java:324)
    at
org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateAllFormulaCells(HSSFFormulaEvaluator.java:315)
    at
org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.evaluateAll(XSSFFormulaEvaluator.java:252)
<< omitted >>

I believe that substituting 

            NumberEval offsetInYearsValue = (NumberEval) args[1];

with

            if (args[1] instanceof RefEval) {
                args[1] = ((RefEval) args[1]).getInnerValueEval();
            }
            NumberEval offsetInYearsValue = (NumberEval) args[1];


resolves the issue

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message