Page 1 of 1

Format a whole Sheet

Posted: Thu Aug 12, 2010 10:25 am
by Steph.Schie
Hi
Is there a way to format a whole Sheet?
For example: A standard font or backgroundcolor.

This would work i guess but may be very slow
XLS.Sheet[0].Range.ItemsRef['A1:IV65536'].FontStyle := [xfsBold];

The file also would grow i guess.
... this isnt a very elegant way of doing it.

I need to format all Cells which are filled.

Re: Format a whole Sheet

Posted: Thu Aug 12, 2010 11:10 am
by Steph.Schie
procedure FormatSheet(sheetNumber: Integer);
var firstRow, lastRow, firstCol, lastCol :Integer;
begin
XlsRw.Sheets[sheetNumber].CalcDimensionsEx;

firstRow := XlsRw.Sheets[sheetNumber].FirstRow;
lastRow := XlsRw.Sheets[sheetNumber].LastRow;
firstCol := XlsRw.Sheets[sheetNumber].FirstCol;
lastCol := XlsRw.Sheets[sheetNumber].LastCol;

XlsRw.Sheets[sheetNumber].Range.Items[firstCol,firstRow,lastCol,lastRow].FontStyle := [xfsBold];
end;

Does the job!