Recent

Author Topic: procedure CopyCol () Libraries » FPSpreadsh  (Read 2737 times)

REDOUANE

  • Newbie
  • Posts: 2
procedure CopyCol () Libraries » FPSpreadsh
« on: September 11, 2017, 08:36:21 pm »
CopyCol () procedure; He does not do his work
Please help copy field
« Last Edit: September 11, 2017, 09:24:11 pm by REDOUANE »

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: procedure CopyCol () Libraries » FPSpreadsh
« Reply #1 on: September 12, 2017, 09:05:51 am »
The tests applied in the the test suite are working. So, what are you doing? Please be more specific.

REDOUANE

  • Newbie
  • Posts: 2
Re: procedure CopyCol () Libraries » FPSpreadsh
« Reply #2 on: September 12, 2017, 07:01:31 pm »
thank you for replying
Here is an example
When using the COPYCOL procedure
fpspreadsheet V 1.8.0

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: procedure CopyCol () Libraries » FPSpreadsh
« Reply #3 on: September 12, 2017, 10:30:41 pm »
Thank you. I see the issue.

Well, to be precise it is not an issue, it is a misunderstanding of what CopyCol is supposed to do. The "columns" of FPSpreadsheet do not store any data - data are stored only in cells; the fpspreadsheet column records (TCol) store format information only, such as column width or the instruction to format all cells in this column in a particular font. Since CopyCol copies only the TCol record, no cell content is transferred.

If you also want to copy cell content then you must iterate through all cells in the column and copy them individually. Like this:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   r1, r2, r: Cardinal;
  4. begin
  5.   sWorkbookSource1.Worksheet.CopyCol(0,1);
  6.  
  7.   r1 := sWorkbookSource1.Worksheet.GetFirstRowIndex;
  8.   r2 := sWorkbookSource1.Worksheet.GetLastRowIndex;
  9.   for r := r1 to r2 do
  10.     sWorkbookSource1.Worksheet.CopyCell(r, 0, r, 1);
  11. end;
« Last Edit: September 13, 2017, 01:08:10 pm by wp »

 

TinyPortal © 2005-2018