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

Example

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

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

{Specify Formula Name - must be same as in Report} Crpe1.Formulas.Add('Formula2'); Crpe1.Formulas.Formula.Text := '2001'; Crpe1.Output := toWindow;

Crpe1.Execute;

Crpe1.Formulas.Delete(0);

Formulas 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.

Formulas IndexOf method

Declaration

function IndexOf(FormulaName: TCrFormulaName): integer;

Type

TCrFormulaName = string;

Description

The IndexOf method takes a Formula name and returns the index position of the Formula item in the current Formulas object.

After the Retrieve method has been called, the Formulas object contains one item for each Formula in the Report. The IndexOf method can be used to determine if a given Formula Name actually exists in the Formulas object before trying to access it.

VCL Reference

298

Example

The following code illustrates the use of the IndexOf method to locate a specific Formula item by its name:

var

nItem: integer; begin

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

{Find a specific formula}

nItem := Crpe1.Formulas.IndexOf('Percentage Sales'); {If it exists...}

if nItem > -1 then begin

with Crpe1.Formulas[nItem] do begin

{Calculate 20% of SALES}

Formula.Text := '{company.SALES} * .20'; end;

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

Formulas Retrieve method

Declaration

function Retrieve: boolean;

Description

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

NOTE: Since the Formulas object also applies to Subreports, the Retrieve method will obtain the Formulas for the Report (or Subreport) that the Subreports object index is currently pointing to. If you want to obtain the Formulas 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 Formulas information for each Subreport.

VCL Reference

299

Example

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

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

Crpe1.Formulas.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.Formulas.Retrieve; end;

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

end;

Formulas Send method

Declaration

function Send: boolean;

Description

The Send method sends the Formulas 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.

We strongly recommend 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 Formulas settings are sent from the Crystal component to the Crystal Reports Print Engine DLL. This is normally handled automatically in the Execute method:

Crpe1.Formulas.Send;

VCL Reference

300

GraphData Properties

GraphData ColGroupN property

Declaration

property ColGroupN: smallint;

Description

The ColGroupN property specifies which Group number in the Report is used to create the values in the columns of the Graph.

Group numbers start with 1.

Use -1 for Default (no change).

Example

The sample code below illustrates the use of the GraphData object to change the Group Field that Columns of the Graph are based on:

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

if Crpe1.GraphData.Count > 0 then Crpe1.GraphData[0].ColGroupN := 2;

Crpe1.Output := toWindow; Crpe1.Execute;

GraphData Direction property

Declaration

property Direction: TCrGraphDirection;

Type

TCrGraphDirection = (Rows, Cols, RowCol, ColRow, Unknown);

VCL Reference

301

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