Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
163
Добавлен:
11.05.2015
Размер:
4.73 Mб
Скачать

AreaFormat Create method

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the AreaFormat object, and does not need to be called in code.

Area Format Delete method

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the AreaFormat object. The "nIndex" parameter represents the number of the item in the AreaFormat object.

Example

The Delete method can be used to manually remove an item from the AreaFormat object:

Crpe1.ReportName := 'C:\Company.rpt';

{Specify Section Name - must be same as in Report} Crpe1.AreaFormat.Add('D'); Crpe1.AreaFormat.KeepTogether := cTrue; Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.AreaFormat.Delete(0);

AreaFormat Destroy method

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

VCL Reference

226

AreaFormat Retrieve method

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the AreaFormat information from the Report and stores it in the AreaFormat object. If no AreaFormat information was found, the call returns False. Be aware that calling Retrieve will first cause the AreaFormat object to be cleared, so any current information stored in it will be removed.

NOTE: Since the AreaFormat object also applies to Subreports, the Retrieve method will obtain the AreaFormat for the Report (or Subreport) that the Subreports object index is currently pointing to. If you want to obtain the AreaFormat information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item. The VCL will store separate AreaFormat information for each Subreport (see Example).

Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.AreaFormat.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Subreports.Retrieve;

{Loop through Reports and Retrieve}

for cnt := 0 to (Crpe1.Subreports.Count - 1) do begin

Crpe1.Subreports[cnt];

Crpe1.AreaFormat.Retrieve; end;

{Set Crpe component back to main Report} Crpe1.Subreports[0];

end;

VCL Reference

227

AreaFormat SectionType method

Declaration

function SectionType: string;

Description

The SectionType method returns the Section Code without the subsection specifier. In other words, if the Section Code for an item is GH1, the SectionType method would return GH; if the SectionCode is Da, the SectionType method would return D.

The primary use for this method is to apply changes to all the Sections in an area, regardless of the sub-section specifier. See the Example for an illustration.

NOTE: Since AreaFormat already works on an "area" rather than "section" basis, this method is of limited use. It can be used with the Group areas, however, since it will ignore Group numbers, and in this way, formatting can be applied to all the Groups.

Example

The following example uses the SectionType method to apply conditional formatting. The formatting is to apply to all Group areas, so the SectionType method can be used in an expression to apply the changes:

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.AreaFormat.Retrieve;

for cnt := 0 to (Crpe1.AreaFormat.Count - 1) do begin

{if the SectionType is Group Header, apply the change} if (Crpe1.AreaFormat[cnt].SectionType = 'GH') then

Crpe1.AreaFormat[cnt].Hide := cTrue;

end; end;

AreaFormat Send method

Declaration

function Send: boolean;

VCL Reference

228

Description

The Send method sends the AreaFormat values to the Crystal Reports Print Engine. This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

It is strongly recommended that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine. If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method. This feature is mainly provided for debugging purposes.

Example

In this example, the AreaFormat settings are sent from the Crystal component to the Crystal Reports Print Engine DLL. This is normally handled automatically in the Execute method:

Crpe1.AreaFormat.Send;

AreaFormatFormulas Properties

AreaFormatFormulas Formula property

Declaration

property Formula: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

The Formula property specifies the actual AreaFormat Formula text. Any values in the AreaFormat Formula that must be seen as strings should be put in double quotes, for example:

Crpe1.AreaFormatFormulas.Formula.Text := '{company.STATE} = "CA"';

Before setting the Formula property, be sure the AreaFormatFormulas object is pointing to the correct Section, and the Section is pointing to the correct Formula Name item. See the Section and Name properties for more details.

See also: Using Variables with Selection Formula, Page 102.

VCL Reference

229

Соседние файлы в папке crystal