Columns set not working
Posted: Tue Aug 23, 2016 7:17 pm
Hello this work fine in XLS v3 but not change the font in v5
Why Columns set not working ?
Thank you in advance
Carl
Why Columns set not working ?
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;