While investigating bug 44449, I found some code in
ValueRecordsAggregate that might also need attention.  Around line 160
there is a reverse iteration loop over the shared formula records.
The fix to 44449 was to limit the content of the sharedFormulas list
(around line 140).  Without that fix, this reverse loop causes a
version of the bug which is much easier to reproduce:  Make a
spreadsheet with a 2 distinct shared formulas - one in Sheet1!A1:A8
and another in Sheet2:A1:A8.  Then use POI to read the cell formula
for Sheet1!A2.  It will incorrectly give the shared formula from the
second sheet.

Once bug fix 44449 is in, this code seems to work ok regardless.  My
guess is that the iteration did not have to be reversed, but the
comments in the code make it seem like there might be a reason.

And now to lay some blame ...
svn blame 
src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java
...
610216       nick                 // Traverse the list of shared formulas in
610216       nick                 //  reverse order, and try to find
the correct one
610216       nick                 //  for us
426082    jheight                 boolean found = false;
426082    jheight                 for (int i=sharedFormulas.size()-1;i>=0;i--) {
...

Changing the loop back to the forward direction does not break any
junits.  I put a comment in the code to that effect.

Can anyone shed light this?  It would be nice to resolve either way.

-Josh

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to