Recent

Author Topic: Copy Cell with property  (Read 455 times)

eldonfsr

  • Hero Member
  • *****
  • Posts: 564
Copy Cell with property
« on: September 30, 2025, 05:48:19 pm »
How i can copy cell with properies the way to write it on new sheet with value and properties...

i tried to get borders and font cell and put on new sheet what i tried to aboy is not copy formulas just values... but i need look same as originial file...



wp

  • Hero Member
  • *****
  • Posts: 13433
Re: Copy Cell with property
« Reply #1 on: September 30, 2025, 07:43:29 pm »
Doesn't the worksheet's CopyCell method do this?

Code: Pascal  [Select][+][-]
  1. program Project1;
  2. uses
  3.   fpSpreadsheet, fpsTypes, fpsOpenDocument;
  4. var
  5.   wBook: TsWorkbook;
  6.   wSheet1, wSheet2: TsWorksheet;
  7. begin
  8.   wBook := TsWorkbook.Create;
  9.   wSheet1 := wBook.AddWorksheet('Sheet 1');
  10.   wSheet2 := wBook.AddWorksheet('Sheet 2');
  11.   wSheet1.WriteNumber(1, 1, 1.23456789, nfFixed, 2);
  12.   wSheet1.WriteFontStyle(1, 1, [fssBold]);
  13.   wSheet1.WriteBorders(1, 1, [cbNorth, cbEast, cbSouth, cbWest]);
  14.   wSheet1.WriteFormula(1, 2, '=B2+1');
  15.   wSheet1.CopyCell(1, 1, 3, 3);           // copy cell B2 to D4, same sheet.
  16.   wSheet2.CopyCell(1, 1, 2, 2, wSheet1);  // copy cell B2 from Sheet1 to Sheet2 cell C3
  17.   wSheet2.CopyCell(1, 2, 2, 3, wSheet1);  // copy cell C2 from Sheet1 to Sheet2 cell D3
  18.   wBook.WriteToFile('test.ods', true);
  19.   wBook.Free;
  20. end.

 

TinyPortal © 2005-2018