You've already forked lazarus-ccr
fpspreadsheet: Fix writing incorrect biff formats (broken in r4353)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4366 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -3771,7 +3771,7 @@ procedure TsSpreadBIFFWriter.WriteSELECTION(AStream: TStream;
|
|||||||
ASheet: TsWorksheet; APane: Byte);
|
ASheet: TsWorksheet; APane: Byte);
|
||||||
var
|
var
|
||||||
activeCellRow, activeCellCol: Word;
|
activeCellRow, activeCellCol: Word;
|
||||||
i: Integer;
|
i, n: Integer;
|
||||||
sel: TsCellRange;
|
sel: TsCellRange;
|
||||||
begin
|
begin
|
||||||
if FWorkbook.ActiveWorksheet <> nil then
|
if FWorkbook.ActiveWorksheet <> nil then
|
||||||
@ -3811,25 +3811,41 @@ begin
|
|||||||
AStream.WriteWord(WordToLE(activeCellCol));
|
AStream.WriteWord(WordToLE(activeCellCol));
|
||||||
|
|
||||||
{ Index into the following cell range list to the entry that contains the active cell }
|
{ Index into the following cell range list to the entry that contains the active cell }
|
||||||
i := ASheet.GetSelectionRangeIndexOfActiveCell;
|
i := Max(0, ASheet.GetSelectionRangeIndexOfActiveCell);
|
||||||
AStream.WriteWord(WordToLE(i));
|
AStream.WriteWord(WordToLE(i));
|
||||||
|
|
||||||
{ Cell range array }
|
{ Cell range array }
|
||||||
|
|
||||||
{ Count of cell ranges }
|
{ Count of cell ranges }
|
||||||
AStream.WriteWord(WordToLE(ASheet.GetSelectionCount));
|
n := ASheet.GetSelectionCount;
|
||||||
|
// Case 1: no selection
|
||||||
{ Write each selected cell range }
|
if n = 0 then
|
||||||
for i := 0 to ASheet.GetSelectionCount-1 do
|
|
||||||
begin
|
begin
|
||||||
sel := ASheet.GetSelection[i];
|
{ Count of cell ranges }
|
||||||
{ Index to first and last row of this selected range }
|
AStream.WriteWord(WordToLE(1));
|
||||||
AStream.WriteWord(WordToLE(sel.Row1));
|
{ Index to first and last row - are the same here }
|
||||||
AStream.WriteWord(WordToLE(sel.Row2));
|
AStream.WriteWord(WordTOLE(activeCellRow));
|
||||||
|
AStream.WriteWord(WordTOLE(activeCellRow));
|
||||||
{ Index to first and last column - they are the same here again. }
|
{ Index to first and last column - they are the same here again. }
|
||||||
{ Note: Even BIFF8 writes bytes here! This is ok because BIFF supports only 256 columns }
|
{ Note: BIFF8 writes bytes here! This is ok because BIFF supports only 256 columns}
|
||||||
AStream.WriteByte(sel.Col1);
|
AStream.WriteByte(activeCellCol);
|
||||||
AStream.WriteByte(sel.Col2);
|
AStream.WriteByte(activeCellCol);
|
||||||
|
end else
|
||||||
|
// Case 2: Selections available
|
||||||
|
begin
|
||||||
|
AStream.WriteWord(WordToLE(n));
|
||||||
|
{ Write each selected cell range }
|
||||||
|
for i := 0 to n-1 do
|
||||||
|
begin
|
||||||
|
sel := ASheet.GetSelection[i];
|
||||||
|
{ Index to first and last row of this selected range }
|
||||||
|
AStream.WriteWord(WordToLE(sel.Row1));
|
||||||
|
AStream.WriteWord(WordToLE(sel.Row2));
|
||||||
|
{ Index to first and last column }
|
||||||
|
{ Note: Even BIFF8 writes bytes here! This is ok because BIFF supports only 256 columns }
|
||||||
|
AStream.WriteByte(sel.Col1);
|
||||||
|
AStream.WriteByte(sel.Col2);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user