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

DiscardSavedData

Declaration

property DiscardSavedData: boolean;

Description

A Report can be created with Saved Data. This means that the data it was last run with is saved with the Report, and unless it is discarded, the Report will by default run with the Saved Data instead of reading the Database. This is sometimes desirable, such as when a Report is being distributed to users who do not have access to the Database but would like to preview and print the Reports anyway.

In most other cases, applications that call Reports should make sure they discard the Saved Data. Setting this property to True will do that. The HasSavedData property can also be checked to see if the Report has Saved Data or not.

Note that if a Report is executed at runtime, and it is still the currently loaded Report in the VCL, running it again will cause it to use the Saved Data from the previous run. Therefore, if running a Report more than once in a row, with different parameters, make sure and set DiscardSavedData to True between each run.

DiscardSavedData Example

This code example sets the DiscardSavedData property to True. Any data saved with the Report, either when the Report was saved in Crystal Reports Designer, or because the Report was run once already, will be discarded:

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

Crpe1.DiscardSavedData := True;

Crpe1.Output := toWindow;

Crpe1.Execute;

Export

Declaration

property Export: TCrpeExport;

Type

TCrpeExport = class(TPersistent)

VCL Reference

21

Description

The Export object is one of the largest in the Crystal component and contains all the options that apply to exporting a Report to one of the supported Export formats. In order to have the Export options apply, the Output property of the Crystal component must be set to Export.

The Destination property determines if the exported file will go to File, to E-mail, to Exchange Folder, or to Application.

The FileName property applies if going to disk file.

The FileType property determines what the export type will be (RTF, Ascii, HTML, ODBC, etc.).

The Email object contains the properties that apply if the Destination is set to Email. When exporting to Email, the FileName property will not apply, but the FileName will be taken from the ReportName. One exception to this rule is the HTML format, in which a FileName can be specified when exporting to Email.

The Exchange object contains the properties that apply if the Destination is set to Exchange.

The ODBC object contains the properties that apply if the Destination is set to ODBCTable.

The Excel5Ext object contains the properties that apply if the FileType is set to Excel5Extended.

The CharSepQuote and CharSepSeparator properties apply if the FileType is set to CharacterSeparated.

The LinesPerPage property applies if the FileType is set to PaginatedText.

The UseRptDateFmt and UseRptNumberFmt properties apply if the FileType is set to one of the following: Records, TabSeparated, Dif, Csv, or CharacterSeparated.

The PromptOnOverwrite property determines if a warning dialog box will appear if the file specified in the FileName property already exists (assuming that the Destination is set to go toFile).

The PromptForOptions property will cause all the Export settings to be ignored, and will instead prompt the user for the various options.

The AppName property applies if the Destination is set to Application.

The Clear property can be used to set the Export object back to its default values. These defaults consist of clearing all the string fields, and setting the following properties:

FileType

:= Ascii;

Destination

:= toFile;

UseRptNumberFmt

:= TCRPE_DEFAULT_USERPTNUMBERFMT;

UseRptDateFmt

:= TCRPE_DEFAULT_USERPTDATEFMT;

LinesPerPage

:= TCRPE_DEFAULT_LINESPERPAGE;

ColumnHeadings

:= False;

PromptForOptions

:= False;

PromptOnOverwrite

:= False;

TCRPE_DEFAULT_USERPTNUMBERFMT= True;

TCRPE_DEFAULT_USERPTDATEFMT = True;

TCRPE_DEFAULT_LINESPERPAGE = 60;

VCL Reference

22

Export Example

Exporting to File in Ascii format:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Output := toExport; Crpe1.Export.Destination := toFile; Crpe1.Export.FileType := Ascii; Crpe1.Export.FileName := 'C:\MyReport.txt'; Crpe1.Execute;

Exporting to File in ODBCTable format: Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Output := toExport;

with Crpe1.Export do begin

Destination := toFile; FileType := ODBCTable; ODBC.Source := 'SQLServer'; ODBC.User := 'Maxwell Smart'; ODBC.Password := 'Agent86'; ODBC.Table := 'ReportTable';

end; Crpe1.Execute;

Export to Email in HTML format:

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

with Crpe1.Export do begin

Destination := toEmailViaMapi; FileType := HTML30;

FileName := 'C:\MyReport.htm'; Email.ToList := 'Maxwell Smart'; Email.CCList := 'The Chief'; Email.Subject := 'Chaos';

Email.Message := 'Would you believe...'; end;

Crpe1.Execute;

VCL Reference

23

Export to Exchange Folder in PaginatedText format:

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

with Crpe1.Export do begin

Destination := toMSExchange; FileType := PaginatedText; LinesPerPage := 25;

Exchange.Profile := 'Microsoft Outlook'; Exchange.Folder := 'Personal Folders@Inbox'; Exchange.Password := 'Agent86';

end; Crpe1.Execute;

Export Properties

Export AppName property, Page 255

Export CharSepQuote property, Page 256

Export CharSepSeparator property, Page 257

Export Destination property, Page 258

Export Email property, Page 260

Properties

¾Export Email CCList property, Page 261

¾Export Email Message property, Page 261

¾Export Email Subject property, Page 262

¾Export Email ToList property, Page 263

¾Export Email VIMBCCList property, Page 263

Methods

¾Export Email Clear method, Page 264

¾Export Email CopyFrom method, Page 265 Export Excel5Ext property, Page 265

Properties

¾Export Excel5Ext Area property, Page 266

¾Export Excel5Ext ColumnHeadings property, Page 267

¾Export Excel5Ext ColumnWidth property, Page 268

¾Export Excel5Ext Constant property, Page 269

¾Export Excel5Ext TabularFormat property, Page 269

VCL Reference

24

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