Bug 44371 - [patch] Added Excel function OFFSET()
Summary: [patch] Added Excel function OFFSET()
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-02-06 22:31 UTC by Josh Micich
Modified: 2008-02-21 07:08 UTC (History)
0 users

svn diff for 9 changed files (30.60 KB, patch)
2008-02-06 22:33 UTC, Josh Micich
Details | Diff
tar bz2 of 2 added files (2.45 KB, patch)
2008-02-06 22:34 UTC, Josh Micich
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Micich 2008-02-06 22:31:21 UTC
Filled out implementation for Offset.java.

Some difficulties were encountered performing this work, because the OFFSET 
function requires access to the workbook/sheet which is not part of the 
evaluate() method signature for all functions implemented so far.  This 
requirement seems to be rare.  A quick browse found one other unimplemented 
function (INDIRECT) with the same problem.

I decided to model this requirement with a dedicated interface 
(FreeRefFunction), which has a similar evaluate method but takes two extra 
parameters.  Some rearranging inside HSSFFormulaEvaluator was necessary to 
invoke FreeRefFunction.evaluate() when needed.  This has left a little 
ugliness in HSSFFormulaEvaluator.invokeOperation().  An alternative approach 
might be to make the OperationEval interface aware of this requirement, but I 
thought the flow on effects might be worse.

A mostly complete implementation of OFFSET() has been added.  The need to 
evaluate area refs on the fly caused some more refactoring within 
HSSFFormulaEvaluator to expose that functionality.

A junit (TestOffset) was added, though this only tests trivial parts of 
Offset.java so far.  More thorough testing can easily be achieved through 
FormulaEvalTestData.xls, but there is a much larger pending change to the same 
file in patch 44364. 

Indirect.java was modified to implement the correct interface.  Javadoc was 
added, but the method is still empty.
Comment 1 Josh Micich 2008-02-06 22:33:17 UTC
Created attachment 21487 [details]
svn diff for 9 changed files
Comment 2 Josh Micich 2008-02-06 22:34:50 UTC
Created attachment 21488 [details]
tar bz2 of 2 added files
Comment 3 Nick Burch 2008-02-21 07:08:26 UTC
Was a little bit of a faff to apply, as didn't include the fix for bug #44410,
but that's probably our fault for not applying your patch quick enough...

Committed to svn trunk