You've already forked lazarus-ccr
fpspreadsheet: Fix issue when moving cells with formulas mentioned in previous commit.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8263 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -2276,6 +2276,7 @@ var
|
|||||||
fromRow, fromCol: Cardinal;
|
fromRow, fromCol: Cardinal;
|
||||||
sheet: TsWorksheet;
|
sheet: TsWorksheet;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
formula: String;
|
||||||
begin
|
begin
|
||||||
if ACell = nil then
|
if ACell = nil then
|
||||||
exit;
|
exit;
|
||||||
@ -2289,7 +2290,16 @@ begin
|
|||||||
fromCol := ACell^.Col;
|
fromCol := ACell^.Col;
|
||||||
|
|
||||||
// Copy cell to new location
|
// Copy cell to new location
|
||||||
|
// Note: In Excel the formula in a moved cell still points to the initial
|
||||||
|
// location. This is different from copying a formula.
|
||||||
|
// --> We must prevent CopyCell from adjusting the formula
|
||||||
|
// --> Erase the formula temporarily.
|
||||||
|
formula := ReadFormula(ACell);
|
||||||
|
DeleteFormula(ACell);
|
||||||
CopyCell(fromRow, fromCol, AToRow, AToCol);
|
CopyCell(fromRow, fromCol, AToRow, AToCol);
|
||||||
|
// Restore the old formula which points to the old location.
|
||||||
|
if formula <> '' then
|
||||||
|
WriteFormula(AToRow, AToCol, formula);
|
||||||
|
|
||||||
// Fix formula references to this cell
|
// Fix formula references to this cell
|
||||||
for i := 0 to FWorkbook.GetWorksheetcount-1 do begin
|
for i := 0 to FWorkbook.GetWorksheetcount-1 do begin
|
||||||
|
Reference in New Issue
Block a user