Page 1 of 1

Copy cell-format-settings to a new cell

Posted: Mon Jan 14, 2008 10:04 am
by Ironarrow
Hi everyone,

I want to use a "normal" (with Excel created) file as a template. So my customers can create their own designs for output.
My program uses two XLSReadWriteII components. One to read the template file and one to create the new output-file.

In the template file, each cell is already formated (currency, float, date, font color, border ect.).

It should work like this (I know this aren't the correct commands, but they show what I want to do):

Code: Select all

XLSTemplate.FileName:='c:\template.xls';
XLSTemplate.Read;

myFormat := XLSTemplate.Sheet[0].GetFormat['A1'];
XLSOutPut.Sheet[0].AsString['A1'] := '24';
XLSOutPut.Sheet[0].SetFormat['A1'] := myFormat;

XLSOutPut.FileName :='myoutput.xls';
XlsOutPut.Write;

The cell A1 is a currency-cell. So the final result in cell A1 in XLSOutput should be 24,00 €.

It would be fine, if fontstyle, font color ect. will be copied, too.

Has anyone an idea how this can be done ??

Regards,

Rainer

Posted: Tue Jan 22, 2008 1:54 pm
by larsa
Hello

Use the Assign method.

Example: XLS.Sheets[0].Cell[0,0].Assign(XLS.Sheets[0].Cell[2,2]);


Lars Arvidsson

Posted: Thu Feb 07, 2008 8:10 am
by Ironarrow
Thank you very much.

I will test it as soon as possible.

Regards,

Rainer