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

Status Example

The code below illustrates the use of Status to determine when the Job has completed:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Output := toWindow; Crpe1.Execute;

{Loop until the Job is finished processing} while Crpe1.Status <> 3 do

Application.ProcessMessages;

Crpe1.CloseJob;

Subreports

Declaration

property Subreports: TCrpeSubreports;

Type

TCrpeSubreports = class(TPersistent)

Description

Many of the properties and sub-class objects on the VCL can apply to the main Report, or any Subreports as well. When Subreports are involved, the Subreports object is used to distinguish which Report the VCL properties are currently pointing to. Since the first item in the Subreports object (Subreports[0]) is always a reference to the main Report, the Subreports object should probably have been called Reports, but for now just bear in mind that Subreports[0] actually refers to the main Report.

The Subreports object maintains a list of Report names, including the Main Report, and any associated Subreports, via the Name property.

The associated section the Subreports are located in is available via the Section property.

The Subreports object can be filled automatically, by using Retrieve, or it can be filled/emptied manually using the Add and Delete methods. Note that Retrieve will not retrieve all of the information about a Report, such as Formulas, Tables, etc. Retrieve for the Subreports object simply gathers the Subreport names and sections, opens a printjob for each Subreport, and creates sub-class objects (Formulas, Tables, etc.) for each Subreport. These subclass objects still need to have their information retrieved using their own Retrieve methods.

The Count method returns the number of items in the Subreports object, and includes the Main Report.

The Clear method is used to remove the Subreport information, which includes the information set for the main Report as well.

Navigating through the Subreports can be accomplished via the default array property: Item, the ItemIndex property, or the Name property. Since Item is a default array index property, it does not need to be specified when making the call: Subreports[1] sets the Crystal component to the first Subreport.

VCL Reference

112

The SubExecute property determines whether Subreports can be run as stand-alone Reports or not. If it is set to True, and the Subreports object is pointing to a Subreport when the Execute method is called, the Subreport will run instead of the main Report.

The NLinks and OnDemand properties are new to SCR 7. They are read-only properties which give further information about the Subreport.

NOTE: It is important to remember that the Subreports object affects almost every other property in the Crystal component. If the Subreports object is changed from the main Report (Subreports[0]) to a Subreport (Subreports[1]), then all of the properties that can apply to Subreports will now be pointing to that Subreport also.

Subreports Example

To obtain the names of the Subreports, read the Name property:

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

for cnt := 0 to (Crpe1.Subreports.Count - 1) do doListBox1.Items.Add(Crpe1.Subreports.Name);

This example shows how to set properties on the main Report and first Subreport, and then run the main Report:

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

{Retrieve the main Report Tables} Crpe1.Tables.Retrieve;

{Set the Path for the first Table} Crpe1.Tables[0].Path := 'C:\Reports\'; {Propagate Path for all main & sub tables} Crpe1.Tables.Propagate := True;

{Point to first Subreport} Crpe1.Subreports[1];

{Set Subreport Selection Formula} Crpe1.Selection.Formula.Text := '{company.STATE} = "CA"'; {Set Output}

Crpe1.Output := toWindow;

{Run the Report - As long as the Subreports.SubExecute is set to False, the main Report will run on Execute, regardless of which Subreport is currently selected}

Crpe1.Execute;

Subreports Properties

Subreports Item property, Page 650

Subreports ItemIndex property, Page 651

VCL Reference

113

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