Page 1 of 1

how to set a default values with version 5

Posted: Sun Jun 02, 2013 7:27 am
by airsoft
Hi,

1) I wonder how can be set a default font name/size and cell alignment in entire sheet

Code: Select all

          with XLS.CmdFormat do
          begin
            Mode := xcfmReplace;
            BeginEdit (XLS [0]);
            Font.Name := 'MS Sans Serif';
            Font.Size := 10;
            Alignment.Vertical := cvaCenter;
            Apply (0, 0, 255, 65535);
          end;
this code almost cause 100% cpu usage on my i5 CPU for more than 2 minutes

2) how can be created a file with 6 sheets in Excel 97 format with default settings like point 1)

3) XLS.CmdFormat.BeginEdit (XLS [0]) - value "0" what means? sheet index?

Regards

Re: how to set a default values with version 5

Posted: Mon Jun 10, 2013 12:12 pm
by larsa
Hello

Don't use something like that. It will create a worksheet with 256 x 65536 blank cells. If you want to set a default format for a whole worksheet, format the columns.
You need update 5.10.25 for this. Example:

Code: Select all

  XLS.CmdFormat.BeginEdit(XLS[0]);
  XLS.CmdFormat.Fill.BackgroundColor.RGB := $FF0000;
  XLS.CmdFormat.ApplyCols(0,XLS_MAXCOL);

Re: how to set a default values with version 5

Posted: Tue Jun 11, 2013 6:14 pm
by airsoft
Hi Lars,

It works, but not exactly as I imagined it

Code: Select all

  X.Sheets [0].Name := 'test sheet';
  X.CmdFormat.BeginEdit (X [0]);
  X.CmdFormat.Mode := xcfmReplace;
  X.CmdFormat.Font.Name := 'Times New Roman CYR';
  X.CmdFormat.Font.Size := 12;
  X.CmdFormat.Alignment.Vertical := cvaCenter;
  X.CmdFormat.ApplyCols (0, XLS_MAXCOLS);
  X.Sheets [0].AsString [0, 0] := 'Христо Марков';
  X.Filename := 'D:\proba.xls';
  X.Write;
  X.Clear;
  X.Version := xvExcel97;
I was expecting the whole sheet to be formatted, not only the cells that I've modified
and another thing..... when I press "Print preview" my 2003 EXCEl says "you have 29 pages to print
row "1" from cols "A" to "IU" i.e. 255 columns, why?

tested version is 5.10.25

Regards,
Hristo Markow