You've already forked lazarus-ccr
fpspreadsheet: Fix biff8 incorrectly reading non-contiguous shared formulas. Fix biff8 writing only contiguous shared formulas.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3594 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -2885,6 +2885,9 @@ end;
|
|||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Determines the cell block sharing the same formula which is used by a given cell
|
Determines the cell block sharing the same formula which is used by a given cell
|
||||||
|
|
||||||
|
Note: the block may not be contiguous. The function returns the outer edges
|
||||||
|
of the range.
|
||||||
|
|
||||||
@param ACell Pointer to the cell being investigated
|
@param ACell Pointer to the cell being investigated
|
||||||
@param ARow1 (output) Top row index of the shared formula block
|
@param ARow1 (output) Top row index of the shared formula block
|
||||||
@param ACol1 (outout) Left column index of the shared formula block
|
@param ACol1 (outout) Left column index of the shared formula block
|
||||||
@ -2912,21 +2915,17 @@ begin
|
|||||||
ACol1 := base^.Col;
|
ACol1 := base^.Col;
|
||||||
ACol2 := ACol1;
|
ACol2 := ACol1;
|
||||||
// ... and go along first COLUMN to find the end of the shared formula block, ...
|
// ... and go along first COLUMN to find the end of the shared formula block, ...
|
||||||
for c := ACol1+1 to GetLastColIndex do
|
for c := ACol1+1 to GetLastOccupiedColIndex do
|
||||||
begin
|
begin
|
||||||
cell := FindCell(ARow1, c);
|
cell := FindCell(ARow1, c);
|
||||||
if (cell = nil) or (cell^.SharedFormulaBase <> base) then
|
if (cell <> nil) and (cell^.SharedFormulaBase = base) then
|
||||||
break
|
|
||||||
else
|
|
||||||
ACol2 := c;
|
ACol2 := c;
|
||||||
end;
|
end;
|
||||||
// ... and go along first ROW to find the end of the shared formula block
|
// ... and go along first ROW to find the end of the shared formula block
|
||||||
for r := ARow1 + 1 to GetLastRowIndex do
|
for r := ARow1 + 1 to GetLastOccupiedRowIndex do
|
||||||
begin
|
begin
|
||||||
cell := FindCell(r, ACol1);
|
cell := FindCell(r, ACol1);
|
||||||
if (cell = nil) or (cell^.SharedFormulaBase <> base) then
|
if (cell <> nil) and (cell^.SharedFormulaBase = base) then
|
||||||
break
|
|
||||||
else
|
|
||||||
ARow2 := r;
|
ARow2 := r;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1024,7 +1024,7 @@ end;
|
|||||||
*******************************************************************}
|
*******************************************************************}
|
||||||
procedure TsSpreadBIFF8Writer.WriteStyle(AStream: TStream);
|
procedure TsSpreadBIFF8Writer.WriteStyle(AStream: TStream);
|
||||||
begin
|
begin
|
||||||
{ BIFF Record header }
|
{ BIFF record header }
|
||||||
AStream.WriteWord(WordToLE(INT_EXCEL_ID_STYLE));
|
AStream.WriteWord(WordToLE(INT_EXCEL_ID_STYLE));
|
||||||
AStream.WriteWord(WordToLE(4));
|
AStream.WriteWord(WordToLE(4));
|
||||||
|
|
||||||
|
@ -2769,38 +2769,16 @@ var
|
|||||||
begin
|
begin
|
||||||
RPNLength := 0;
|
RPNLength := 0;
|
||||||
|
|
||||||
// Determine cell range covered by the shared formula in ACell.
|
|
||||||
// Find range of cells using this shared formula
|
|
||||||
r1 := ACell^.Row; r2 := r1;
|
|
||||||
c1 := ACell^.Col; c2 := c1;
|
|
||||||
r := r1;
|
|
||||||
c := c1;
|
|
||||||
while c <= FWorksheet.GetLastColIndex do
|
|
||||||
begin
|
|
||||||
cell := FWorksheet.FindCell(r, c);
|
|
||||||
if (cell <> nil) and (cell^.SharedFormulaBase = ACell^.SharedFormulaBase) then
|
|
||||||
c2 := c
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
inc(c);
|
|
||||||
end;
|
|
||||||
c := c1;
|
|
||||||
while r <= FWorksheet.GetLastRowIndex do
|
|
||||||
begin
|
|
||||||
cell := FWorksheet.FindCell(r, c);
|
|
||||||
if (cell <> nil) and (cell^.SharedFormulaBase = ACell^.SharedFormulaBase) then
|
|
||||||
r2 := r
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
inc(r);
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Write BIFF record ID and size
|
// Write BIFF record ID and size
|
||||||
AStream.WriteWord(WordToLE(INT_EXCEL_ID_SHAREDFMLA));
|
AStream.WriteWord(WordToLE(INT_EXCEL_ID_SHAREDFMLA));
|
||||||
recordSizePos := AStream.Position;
|
recordSizePos := AStream.Position;
|
||||||
AStream.WriteWord(0); // This is the record size which is not yet known here
|
AStream.WriteWord(0); // This is the record size which is not yet known here
|
||||||
startPos := AStream.Position;
|
startPos := AStream.Position;
|
||||||
|
|
||||||
|
// Determine (maximum) cell range covered by the shared formula in ACell.
|
||||||
|
// Note: it is possible that the range is not contiguous.
|
||||||
|
FWorksheet.FindSharedFormulaRange(ACell, r1, c1, r2, c2);
|
||||||
|
|
||||||
// Write borders of cell range covered by the formula
|
// Write borders of cell range covered by the formula
|
||||||
WriteSharedFormulaRange(AStream, r1, c1, r2, c2);
|
WriteSharedFormulaRange(AStream, r1, c1, r2, c2);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user