Can copy area ? lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- dodgex · 2025-05-12 10:08 Does it support copy an area and insert it on another row? like this by ole:     ExcelApp.ActiveSheet.Rows['1:10' ].Select;     ExcelApp.Selection.Copy;     ExcelApp.ActiveSheet.Rows['11:11'].Select;     ExcelApp.Selection.Insert; ---------------------------------------------------------------------- wp · 2025-05-12 15:58 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;uses  fpSpreadsheet, xlsxOOXML;var  wBook: TsWorkbook;  wSheet: TsWorksheet;  r, c: Cardinal;begin  wBook := TsWorkbook.Create;  wSheet := wBook.AddWorksheet('Sheet 1');   // Populate work sheet  for r := 0 to 10 do    for c := 0 to 5 do      wSheet.WriteNumber(r, c, 100*r + c);   // Copy range C3:D6 to M1:N5  for r := 2 to 5 do    for c := 2 to 3 do      wSheet.CopyCell(r, c, r-2, c+10);   wBook.WriteToFile('test.xlsx', true);  wBook.Free;end. ---------------------------------------------------------------------- dodgex · 2025-05-13 09:49 Quote from: wp on May 12, 2025, 05:58:31 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;uses  fpSpreadsheet, xlsxOOXML;var  wBook: TsWorkbook;  wSheet: TsWorksheet;  r, c: Cardinal;begin  wBook := TsWorkbook.Create;  wSheet := wBook.AddWorksheet('Sheet 1');   // Populate work sheet  for r := 0 to 10 do    for c := 0 to 5 do      wSheet.WriteNumber(r, c, 100*r + c);   // Copy range C3:D6 to M1:N5  for r := 2 to 5 do    for c := 2 to 3 do      wSheet.CopyCell(r, c, r-2, c+10);   wBook.WriteToFile('test.xlsx', true);  wBook.Free;end. Thank you for your help, But this is just copying the values of cells. Can we copy the values and styles within one range and copy them in another row? ---------------------------------------------------------------------- wp · 2025-05-13 11:06 Quote from: dodgex on May 13, 2025, 11:49:54 amBut this is just copying the values of cells. Can we copy the values and styles within one range and copy them in another row? No, it copies also formulas and cell formatting: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;uses  Sysutils, fpSpreadsheet, fpsTypes, xlsxOOXML; function RandomBrightColor: DWord;var  R, G, B: Byte;begin  R := $FF - Random($33);  G := $FF - Random($33);  B := $FF - Random($33);  Result := R + G shl 8 + b shl 16;end; var  wBook: TsWorkbook;  wSheet: TsWorksheet;  cell: PCell;  r, c: Cardinal;begin  RandSeed := 1;   wBook := TsWorkbook.Create;  wSheet := wBook.AddWorksheet('Sheet 1');   // Populate work sheet  for r := 0 to 10 do    for c := 0 to 5 do    begin      if c = 3 then        // Write a formula        cell := wSheet.WriteFormula(r, c, '=Row(A' + IntToStr(r+1)+ ')')      else        // Write constant values        cell := wSheet.WriteNumber(r, c, 100*r + c);      // Write some random formatting      wSheet.WriteBackgroundColor(cell, RandomBrightColor);      if Random(2) =0 then        wSheet.WriteFontStyle(cell, [fssBold, fssItalic]);    end;   // Copy range C3:D6 to M1:N5  for r := 2 to 5 do    for c := 2 to 3 do      wSheet.CopyCell(r, c, r-2, c+10);   wBook.WriteToFile('test.xlsx', true);  wBook.Free;end. ---------------------------------------------------------------------- dodgex · 2025-05-14 03:19 Quote from: wp on May 13, 2025, 01:06:25 pmQuote from: dodgex on May 13, 2025, 11:49:54 amBut this is just copying the values of cells. Can we copy the values and styles within one range and copy them in another row? No, it copies also formulas and cell formatting: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;uses  Sysutils, fpSpreadsheet, fpsTypes, xlsxOOXML; function RandomBrightColor: DWord;var  R, G, B: Byte;begin  R := $FF - Random($33);  G := $FF - Random($33);  B := $FF - Random($33);  Result := R + G shl 8 + b shl 16;end; var  wBook: TsWorkbook;  wSheet: TsWorksheet;  cell: PCell;  r, c: Cardinal;begin  RandSeed := 1;   wBook := TsWorkbook.Create;  wSheet := wBook.AddWorksheet('Sheet 1');   // Populate work sheet  for r := 0 to 10 do    for c := 0 to 5 do    begin      if c = 3 then        // Write a formula        cell := wSheet.WriteFormula(r, c, '=Row(A' + IntToStr(r+1)+ ')')      else        // Write constant values        cell := wSheet.WriteNumber(r, c, 100*r + c);      // Write some random formatting      wSheet.WriteBackgroundColor(cell, RandomBrightColor);      if Random(2) =0 then        wSheet.WriteFontStyle(cell, [fssBold, fssItalic]);    end;   // Copy range C3:D6 to M1:N5  for r := 2 to 5 do    for c := 2 to 3 do      wSheet.CopyCell(r, c, r-2, c+10);   wBook.WriteToFile('test.xlsx', true);  wBook.Free;end. Thank you, I'll give it a try