Columns set not working

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
agfcpc3
Posts: 3
Joined: Tue Aug 23, 2016 7:00 pm

Columns set not working

Post by agfcpc3 »

Hello this work fine in XLS v3 but not change the font in v5
Why Columns set not working ? :shock:

Thank you in advance
Carl

Code: Select all


implementation
uses       Xc12DataStyleSheet5, ShellAPI{ShellExecute} ;

procedure TForm1.FormCreate(Sender: TObject);
var St:array[0..255] of char;
  procedure MoreData5(sFormat:string;nCol:byte);
    begin
     XLS5.Sheets[0].AsString[nCol,0] := 'format '+sFormat;
     XLS5.Sheets[0].Columns[nCol].NumberFormat:= sFormat;
     XLS5.Sheets[0].AsFloat[nCol,2] := 1234.01;
     XLS5.Sheets[0].AsFloat[nCol,3] := 1234.1;
     XLS5.Sheets[0].AsFloat[nCol,4] := 12;
     XLS5.Sheets[0].AsFloat[nCol,5] := -1234.01;
     XLS5.Sheets[0].AsFloat[nCol,6] := -1234.1;
     XLS5.Sheets[0].AsFloat[nCol,7] := -12;
    end;
begin
  XLS5.Clear();
  XLS5.Sheets[0].Columns.AddIfNone(0,10); 
  // Set the width of a column in characters
  XLS5.Sheets[0].Columns[6].CharWidth := 12;
  // Set the width of a column in pixels
  XLS5.Sheets[0].Columns[7].PixelWidth := 30;
  // Format cell color of all cells in the column

  //  xcRed; // error in  v5

  //XLS5.Sheets[0].Columns[8].FillPatternForeColor := xcRed; // error v5
  // Format font style of all cells in the column

  XLS5.Sheets[0].Columns[9].FontStyle := [xfsBold];
  //

  XLS5.Sheets[0].Columns[0].FontSize :=  8;
  XLS5.Sheets[0].Columns[2].FontSize := 11;
  XLS5.Sheets[0].Columns[4].FontSize := 14;

  MoreData5('00000.00',0);
  MoreData5('#,##0.00',2);
  MoreData5('##,###,##0.00 ;[Red](##,###,##0.00);',4);
  MoreData5('##,###,##0.00 ;[Red](##,###,##0.00);',9); // Bold


  XLS5.Filename := 'e:\adelphi\TestingXLS5_'+ FormatDateTime('hhnnss',now)+ '.xlsx';
  XLS5.Write;

  ShellExecute(Handle,'open',StrPCopy(St,XLS5.Filename),nil,nil,SW_SHOW);

  Application.Terminate;
end;

larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Columns set not working

Post by larsa »

Hello

Please take a look at the FormatCells sample.
Lars Arvidsson, Axolot Data
agfcpc3
Posts: 3
Joined: Tue Aug 23, 2016 7:00 pm

Re: Columns set not working

Post by agfcpc3 »

I have not problem with

XLS5.CmdFormat.BeginEdit(XLS5[0]);
XLS5.CmdFormat.Number.Format := '##,###,##0.00 ;[Red](##,###,##0.00);';
XLS5.CmdFormat.ApplyCols(10,10);

I have very much units with for example

XLS5.Sheets[0].Columns[1].NumberFormat := '#####0';
XLS5.Sheets[0].Columns[2].NumberFormat := '##,###,##0.00 ;[Red](##,###,##0.00);';

Why do you not repair your problem ?
Thank you in advance
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Columns set not working

Post by larsa »

Hello

I can't reproduce the problem. Your code works fine here.
Lars Arvidsson, Axolot Data
Post Reply