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

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

Export Send method

Declaration

function Send: boolean;

Description

The Send method sends the Export 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 Export settings are sent from the Crystal component to the Crystal Reports Print Engine DLL. This is normally handled automatically in the Execute method:

Crpe1.Export.Send;

Formulas Properties

Formulas Formula property

Declaration

property Formula: TCrpeString;

VCL Reference

290

Type

TCrpeString = class(TStringList)

Description

The Formula property contains the actual text of the Formula. To assign a new value to the Formula property, any of the following methods can be used (or any other method that is valid for a StringList):

1)Crpe1.Formulas.Formula.Assign('new text');

2)Crpe1.Formulas.Formula.Text := 'new text';

3)Crpe1.Formulas.Formula.Clear; Crpe1.Formulas.Formula[0] := 'new text';

4)Crpe1.Formulas.Formula.SetText(PChar('new text'));

The new Formula string must conform to Seagate Crystal Reports syntax requirements.

See also: Using Variables with Formulas, Volume 1, Chapter 7.

Example

The following code shows how the Formula property is used to store a new formula.

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

Crpe1.Formulas.Formula.Assign('({company.SALES} * 10) / 100'); Crpe1.Output := toWindow;

Crpe1.Execute;

Formulas Item property

Declaration

property Item[const nIndex: integer]: TCrpeFormulas;

Description

The Item property is a default array property. It is read-only, and only available at runtime. It's primary use is to provide an easy way to navigate through the various items stored in the Formulas object, allowing the object to be treated like an array.

Item is a default property, so it does not need to be specified when using the subscript: Formulas[2] is the same as Formulas.Item[2].

Item returns a reference to itself, so the Formulas properties can be used right after the subscript: Formulas[2].Name := 'Formula1';

VCL Reference

291

Example

Since Item is a default array property, the following two blocks of code do the same thing:

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

{Set Formulas to the 3rd formula} Crpe1.Formulas.Item[2];

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

{Set Formulas to the 3rd formula} Crpe1.Formulas[2];

Formulas ItemIndex property

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current Formulas item number, or set the Formulas object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox. This Index is updated whenever the Item property is used (Formulas[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.

Example

The following code illustrates the use of the ItemIndex property to make sure the Formulas object is pointing to the first Formula:

if Crpe1.Formulas.ItemIndex <> 0 then Crpe1.Formulas[0];

VCL Reference

292

Formulas Name property

Declaration

property Name: TCrFormulaName;

Type

TCrFormulaName = string;

Description

The Name property specifies the Name of the Formula. It is a key property, and therefore serves as a lookup; that is, assigning it a value will cause the Formulas object to point to the item that has a Formula Name with the same value. Before using the Name property to navigate through the Formulas, the Retrieve method should be called, or the manual Add method.

Example

The following code uses the Formula Name property to point the Formulas object to the specified formula. It then assigns a new formula text to the Formula property:

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

{Set the Formulas object to the "Formula One" item} Crpe1.Formulas.Name := 'Formula One';

{Assign a new formula to the Formula property} Crpe1.Formulas.Formula.Text := '{table.NUM} * 100'; Crpe1.Output := toWindow;Crpe1.Execute;

Formulas Methods

Formulas Add method

Declaration

procedure Add(FormulaName: TCrFormulaName);

Type

TCrFormulaName = string;

VCL Reference

293

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