https://bz.apache.org/bugzilla/show_bug.cgi?id=62254

            Bug ID: 62254
           Summary: OFFSET function fails when 2nd or 3rd arguments are
                    missing
           Product: POI
           Version: 3.17-FINAL
          Hardware: PC
            Status: NEW
          Severity: minor
          Priority: P2
         Component: SS Common
          Assignee: dev@poi.apache.org
          Reporter: gallon.fi...@gmail.com
  Target Milestone: ---

Created attachment 35836
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35836&action=edit
patch

According to the Microsoft documentation, 2 and 3 arguments to the OFFSET
function are mandatory. However, Excel 2010 allows the function to be written
as OFFSET(ref, , ); empty arguments are treated as zeros. 

The patch for Offset.java seems pretty easy to implement:
172,173c172,173
<                       int rowOffset = evaluateIntArg(args[1], srcCellRow,
srcCellCol);
<                       int columnOffset = evaluateIntArg(args[2], srcCellRow,
srcCellCol);
---
>                       int rowOffset = (args[1] instanceof MissingArgEval) ? 0 
> : evaluateIntArg(args[1], srcCellRow, srcCellCol);
>                       int columnOffset = (args[2] instanceof MissingArgEval) 
> ? 0 : evaluateIntArg(args[2], srcCellRow, srcCellCol);

I also attach a test case

There was a patch https://bz.apache.org/bugzilla/show_bug.cgi?id=58339 that
introduced the same behavior for optional arguments 4, 5.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to