Hello,
I have a cell which has a specific format and I would like to copy the format to a new cells.
The cell contains basically a bunch of text. The text is multi-line.
The first 50 rows in my sheet is formated as follows:
E.g.
========================================================
This is a sample for Axolot
This format is basically for demonstration
text
text
text
========================================================
I tried using the following command, but it does not work.
XLS.CopyCells(ACurrSheet,2,2,2,2,ACurrSheet,2,AIndex,[ccoAdjustCells,ccoForceAdjust,ccoCopyCondFmt]);
I saw a sample before in a thread called "Copy cell-format-settings to a new cell" and it says to use the Assign method, but using the method is not possible:
XLS.Sheets[0].Cell[0,0].Assign(XLS.Sheets[0].Cell[2,2]); .
I also tried also the following code but I get access violation when assigning the second cell in my loop:
XLS.Sheet[ACurrSheet].Cell[2,AIndex].Format.Assign(XLS.Sheets[ACurrSheet].Cell[2,2].Format);
So, after all, how can I copy the the formats from another cell?
Thanks,
Fabio
How to copy cell format to a new cell
Re: How to copy cell format to a new cell
Hello
Your first example shall work, but omit the copy options. Just use: XLS.CopyCells(ACurrSheet,2,2,2,2,ACurrSheet,2,AIndex);
Your first example shall work, but omit the copy options. Just use: XLS.CopyCells(ACurrSheet,2,2,2,2,ACurrSheet,2,AIndex);
Lars Arvidsson, Axolot Data
Re: How to copy cell format to a new cell
Hello Lars,
[quote="larsa"]Just use: XLS.CopyCells(ACurrSheet,2,2,2,2,ACurrSheet,2,AIndex);[/quote]
It did the job.
I also found another way to do it.
XLS.Sheet[ACurrSheet].AsRichText[2,AIndex] := XLS.Sheets[ACurrSheet].AsRichText[2,2];
Thanks for the answer.
Br,
Fabio
[quote="larsa"]Just use: XLS.CopyCells(ACurrSheet,2,2,2,2,ACurrSheet,2,AIndex);[/quote]
It did the job.
I also found another way to do it.
XLS.Sheet[ACurrSheet].AsRichText[2,AIndex] := XLS.Sheets[ACurrSheet].AsRichText[2,2];
Thanks for the answer.
Br,
Fabio