how to set a default values with version 5

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
airsoft
Posts: 13
Joined: Sun Mar 13, 2005 5:41 pm
Contact:

how to set a default values with version 5

Post 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
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: how to set a default values with version 5

Post 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);
Lars Arvidsson, Axolot Data
airsoft
Posts: 13
Joined: Sun Mar 13, 2005 5:41 pm
Contact:

Re: how to set a default values with version 5

Post 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
Post Reply