Excel sometimes saves FormulaRecords with the 'shared record' flag set, but with no corresponding SharedFormulaRecord. The correct operation is to leave the FormulaRecord as-is. POI was making a mistake of using SharedFormulaRecords that happen to match the row and column ranges, but come from subsequent sheets. (Excel does not define shared formulas across sheets). The bug results in some cells apparently having formulas from the corresponding cell on another sheet. (!) The solution was to make ValueRecordsAggregate.construct() only consider SharedFormulaRecords for the current sheet.
Created attachment 21554 [details] svn diff of added junit test case and bug fix to ValueRecordsAggregate
Created attachment 21555 [details] tar bz2 of one added test spreadsheet file
Thanks for this patch, applied to svn trunk