FlexCel Studio for VCL/LCL
ContentsIndex
PreviousUpNext
TFlexCelImport.AddFormat Method

Adds a new format to the global format list.

Pascal
function AddFormat(const Fmt: TFlxFormat): integer;
C++
__fastcall int AddFormat(const TFlxFormat Fmt);
Parameters 
Description 
const Fmt: TFlxFormat 
TFlxFormat you want to add. 

This function adds a new XF record to the global format list and returns its id. 

If the format already exists, it won't be added again and the function will return the id of the existing XF. 

 

For example if you have:

Fmt:=FlexCelImport1.FormatList[15];
Fmt.Font.Name:='Courier';

 

and FlexCelImport1.AddFormat(Fmt) returns 33, then calling FlexCelImport1.AddFormat(Fmt) again will return 33 again, and no new format will be added. 

 

But while this code is valid:

FlexCelImport.CellFormat[1,1]:=FlexCelImport1.AddFormat(Fmt);
FlexCelImport.CellFormat[2,1]:=FlexCelImport1.AddFormat(Fmt);
FlexCelImport.CellFormat[3,1]:=FlexCelImport1.AddFormat(Fmt);
FlexCelImport.CellFormat[4,1]:=FlexCelImport1.AddFormat(Fmt);

 

It is more efficient to write

XF:= FlexCelImport1.AddFormat(Fmt);
FlexCelImport.CellFormat[1,1]:=XF;
FlexCelImport.CellFormat[2,1]:=XF:
FlexCelImport.CellFormat[3,1]:=XF;
FlexCelImport.CellFormat[4,1]:=XF;

 

To create a new format from scratch, you can use GetDefaultFormat 

 

Copyright (c) 2002-2008 TMS Software. All rights reserved.
What do you think about this topic? Send feedback!