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

PrintOptions OutputFileName property

NOTE: This property requires Seagate Crystal Reports 7.0 or higher.

Declaration

property OutputFileName: TCrPrintFileName;

Type

TCrPrintFileName = string; {limited to 512 characters}

Description

The OutputFileName property can be used to print a Report to File. It must not exceed 512 characters in length.

Example

This code example changes the PrintOption properties to print to a file:

Crpe1.ReportName := 'MyReport.rpt';

Crpe1.Output := toPrinter;

Crpe1.PrintOptions.OutputFileName := 'C:\Company.prn';

Crpe1.Execute;

PrintOptions PromptForOptions property

Declaration

property PromptForOptions: boolean

Description

The PromptForOptions property can be used to bring up a dialog box that will prompt the user for the various PrintOption property values. This dialog box is the same that appears when the Print button on the Preview Window is clicked, and looks like this:

VCL Reference

508

The dialog box will appear whenever the Send method is called (provided that PromptForOptions is set to True). The Send method is automatically called whenever the Execute method for the component is called. However it may be called manually as well.

This may be desirable in the event that you wish the PrintOptions dialog box to appear with certain default options other than those stored in the current Report. In such a case, the PrintOptions properties can first be set to the desired values, then sent into the Report, and then when the dialog later appears, it will be pre-set to those values. See the Example for code details.

Example

The following code illustrates how to use the PromptForOptions property of the PrintOptions object. The PrintOptions dialog will appear with the values that are specified in the original Report, which may not be the same as what are specified in the Crystal component. In order to get the dialog to appear with the current VCL options, we set the Options in the VCL, and then do a Send. This updates the Report with the new values, and then when the dialog appears, it has those values as default. Note that normally it is not necessary to call Send since this is done at Execute

This particular case is an exception:

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

{First we turn off the Prompt} Crpe1.PrintOptions.PromptForOptions := False; {Set the Options we want} Crpe1.PrintOptions.Copies := 3; Crpe1.PrintOptions.Collation := Collated; Crpe1.PrintOptions.StartPage := 2;

{Send those values into the Report} Crpe1.PrintOptions.Send;

{Now turn the Prompt on} Crpe1.PrintOptions.PromptForOptions := True;

{When Execute is called, the PrintOptions dialog will appear} Crpe1.Execute;

Here is the same example, but in this case, we are not worried about what defaults the PrintOptions dialog appears with, so there is no need to do a Send:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Output := toPrinter; Crpe1.PrintOptions.PromptForOptions := True;

{When Execute is called, the PrintOptions dialog will appear} Crpe1.Execute;

VCL Reference

509

PrintOptions StartPage property

Declaration

property StartPage: Word;

Description

StartPage determines which page the printing will start with.

The default VCL setting for StartPage is zero (0).

Setting StartPage to zero (0) will cause printing to begin with the first page of the Report.

NOTE: This property only applies if Output is toPrinter.

Example

This code example changes the PrintOption properties to print out two copies of pages 2 & 3 from the Report, collated:

Crpe1.ReportName := 'MyReport.rpt'; Crpe1.Output := toPrinter;

with Crpe1.PrintOptions do begin

Collation := Collated; Copies := 2;

StartPage := 2;

StopPage := 3; end; Crpe1.Execute;

PrintOptions StopPage property

Declaration

property StopPage: Word;

Description

StopPage determines which page the printing will stop with.

The default VCL setting for StopPage is zero (0).

Setting StopPage to zero (0), or 65535, will cause printing to go from the StartPage to the last page of the Report.

NOTE: This property only applies if Output is toPrinter.

VCL Reference

510

Example

This code example changes the PrintOption properties to print out two copies of pages 2 & 3 from the Report, collated:

Crpe1.ReportName := 'MyReport.rpt'; Crpe1.Output := toPrinter;

with Crpe1.PrintOptions do begin

Collation := Collated; Copies := 2;

StartPage := 2;

StopPage := 3; end; Crpe1.Execute;

PrintOptions Methods

PrintOptions Clear method

Declaration

procedure Clear;

Description

The Clear method can be used to set the PrintOptions properties back to their default values:

Copies :=

TCRPE_DEFAULT_PRINTERCOPIES;

{1}

Collation

:= DefaultCollation;

{No change}

OutputFileName := '';

 

PromptForOptions := False;

 

StartPage

:= TCRPE_DEFAULT_STARTPAGE;

{0}

StopPage := TCRPE_DEFAULT_STOPPAGE;

{0}

It is called automatically if the Clear method is called for the main component, but may be called in code as needed.

Example

This line of code clears the PrintOptions properties:

Crpe1.PrintOptions.Clear;

VCL Reference

511

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