You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2013/05/31 09:46:19 UTC

[Bug 55032] New: if a formula contains optional argument, it throws a runtime exception

https://issues.apache.org/bugzilla/show_bug.cgi?id=55032

            Bug ID: 55032
           Summary: if a formula contains optional argument, it throws a
                    runtime exception
           Product: POI
           Version: 3.8
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: hawkchen@potix.com

Problem Description:

if you enter a formula like
=PV(0.08/12, 20*12, 500, ,0)

Notice the 4th argument is missing. In this case, 4th and 5th arguments are
both optional.


Actual:
it throws java.lang.RuntimeException: Unexpected arg eval type
(org.apache.poi.ss.formula.eval.MissingArgEval)


Expected:
It seems it cannot accept an optional argument in the middle of argument list.
But Excel can accept and treat the omitted arguments as 0.

-- 
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


[Bug 55032] if a formula contains optional argument, it throws a runtime exception

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55032

hawkchen@potix.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hawkchen@potix.com
                 OS|                            |All

-- 
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


[Bug 55032] if a formula contains optional argument, it throws a runtime exception

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55032

--- Comment #1 from hawkchen@potix.com ---
Suggested solution:
in
public abstract class FinanceFunction implements Function3Arg, Function4Arg {
...
    public ValueEval evaluate(ValueEval[] args, int srcRowIndex, int
srcColumnIndex) {
        switch (args.length) {
            case 3:
                return evaluate(srcRowIndex, srcColumnIndex, args[0], args[1],
args[2], DEFAULT_ARG3, DEFAULT_ARG4);
            case 4:
                return evaluate(srcRowIndex, srcColumnIndex, args[0], args[1],
args[2], args[3], DEFAULT_ARG4);
            case 5:
                return evaluate(srcRowIndex, srcColumnIndex, args[0], args[1],
args[2], args[3], args[4]);
        }
        return ErrorEval.VALUE_INVALID;
    }

Convert MissArgEval to DEFAULT_ARG3 or DEFAULT_ARG4 in case 4 and case 5.

-- 
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