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

Example

The following example copies all the Exchange property values to a temporary TCrpeExportExchange object:

var

tempExchange : TCrpeExportExchange; begin

tempExchange := TCrpeExportExchange.Create; tempExchange.CopyFrom(Crpe1.Export.Exchange); {...later, when finished with the temp object...} tempExchange.Free;

end;

Export FileName property

Declaration

property FileName: TCrExportFileName;

Type

TCrExportFileName = string[255];

Description

FileName holds the name (and path) of the file that will be created when exporting a Report. This property only applies when the Export Destination is set toFile, except in the case of HTML, where the FileName can be used even when going to Email or Exchange.

Example

Exporting to File in Ascii format:

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

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := Ascii;

Crpe1.Export.FileName := 'C:\MyReport.txt';

Crpe1.Execute;

VCL Reference

276

Export FileType property

Declaration

property FileType: TCrExportType;

Type

TCrExportType = (Records, TabSeparated, Ascii, Dif, Csv, CharacterSeparated, TabSeparatedText, CrystalReportRPT, Excel2, Excel3, Excel4, LotusWK1, LotusWK3, LotusWKS, RTF, WordForWindows, Excel5, HTML30, HTML32ext, HTML32std, ODBCTable, PaginatedText, Excel5Extended, ReportDefinition);

Description

The FileType property determines what kind of Export format will be used when a Report is exported (i.e. when Output is set toExport). There are 24 options (WordPerfect, WordForDOS, and QuattroPro are only available in 16-bit, and are not included in the 32-bit version of the component):

Option

Description

 

 

 

 

Ascii

Text style. Saves the data in ASCII text format with all values separated by

 

spaces. This style looks most like the printed page.

 

 

CharacterSeparated

Saves the data as character separated values in ASCII text format. All values

 

are separated by a character or characters specified by CharSepSeparator and

 

CharSepQuote properties. Applicable options: UseRptDateFmt,

 

UseRptNumberFmt, CharSepQuote, CharSepSeparator.

 

 

CrystalReportRPT

Standard Seagate Crystal Reports format is used. Most often used for sending

 

the Report to another user via e-mail.

 

 

Csv

Comma separated values. Encloses alphanumeric field data in quotes and

 

separates fields with commas. Applicable options: UseRptDateFmt,

 

UseRptNumberFmt.

Dif

Saves the data in data interchange format. This format is often used for the

 

transfer of data between different spreadsheet programs. Applicable options:

 

UseRptDateFmt, UseRptNumberFmt.

 

 

Excel2

Exports the Report as a Microsoft Excel 2.1 Worksheet.

 

 

Excel3

Exports the Report as a Microsoft Excel 3.0 Worksheet.

Excel4

Exports the Report as a Microsoft Excel 4.0 Worksheet.

 

 

Excel5

Uses Excel 5 format to save the data in the Report.

 

 

Excel5Extended

Uses an Excel 5 Extended format to save the data in the Report. This is similar

 

to Excel5 format, but with extra options. Applicable options: Excel5Ext.

VCL Reference

277

Option

Description

 

 

 

 

HTML30

Uses HTML 3 format to save the data in the Report. Applicable options:

 

FileName.

HTML32ext

Uses the Internet Explorer version of HTML to save the data in the Report.

 

Applicable options: FileName.

 

 

HTML32std

Uses the Netscape version of HTML to save the data in the Report. Applicable

 

options: FileName.

LotusWK1

Exports the Report as a Lotus 1-2-3 WK1 format worksheet.

 

 

LotusWK3

Exports the Report as a Lotus 1-2-3 WK3 format worksheet.

 

 

LotusWKS

Exports the Report as a Lotus 1-2-3 WKS format worksheet.

 

 

ODBCTable

Exports to a database format corresponding to a specified ODBC Data Source.

 

Applicable options (in ODBC sub-class): Source, User, Password, Table.

 

 

PaginatedText

Exports the Report to Text with Page Headers/Footers. Applicable options:

 

LinesPerPage.

 

 

Records

Record style (columns of values). Does not use commas or separators.

 

Outputs every record with a fixed field width. Applicable options:

 

UseRptDateFmt, UseRptNumberFmt.

 

 

ReportDefinition

Exports a text file of descriptive details about the Report. Useful for

 

cataloging Report design information.

RTF

Saves the data in Rich Text Format.

TabSeparated

Tab separated values. Presents data in tabular form. Encloses alphanumeric

 

field data in quotes and separates fields with tabs. Applicable options:

 

UseRptDateFmt, UseRptNumberFmt.

 

 

TabSeparatedText

Saves the data in ASCII text format with all values separated by tabs.

WordForWindows

Uses the Microsoft Word for Windows format to save the data in the Report.

 

 

Example

Exporting to File in Ascii format:

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

Crpe1.Output := toExport;

Crpe1.Export.Destination := toFile;

Crpe1.Export.FileType := Ascii;

Crpe1.Export.FileName := 'C:\MyReport.txt';

Crpe1.Execute;

VCL Reference

278

Export LinesPerPage property

Declaration

property LinesPerPage: Word;

Description

LinesPerPage is an option that applies when PaginatedText is chosen as the Export FileType. It indicates the number of lines to be printed before the page break. The default is 60 lines. If PromptForOptions is True, the user will be prompted for the LinesPerPage value.

Example

Export to Exchange Folder in PaginatedText format:

Crpe1.ReportName := 'C:\MyReport.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 ODBC Property

Declaration

property ODBC: TCrpeExportODBC;

Type

TCrpeExportODBC = class(TPersistent)

VCL Reference

279

Description

The ODBC object encompasses the properties needed to specify an ODBC Table destination for Export. The four properties are:

Source

: Must be a valid ODBC Data Source Name

User

: Must be a valid UserID (if required)

Password

: Must be a valid Password (if required)

Table

: Specifies the name of the Table to be created. The Table must not already exist or the

 

Export will fail.

If the ODBC Data Source is an SQL-type (Oracle, SQLServer, Sybase, etc.), you must have rights to create a Table on the Server.

If the ODBC Data Source is of PC-type (Paradox, dBase, FoxPro, etc.), the resulting Table will be created as a file in the directory specified in the ODBC Data Source. User and Password are not normally required for these types of Data Sources.

Some of the PC-type Data Sources (such as dBase) may not be able to create Tables with names longer than 8 characters. In this case, the Table name you specify will be truncated if it is over 8 characters.

NOTE: There currently seems to be a problem exporting to ODBC when the destination is Email. The Table will be created on the ODBC Data Source, but the Email send will fail. If you need to export an ODBC table to Email, it will have to be done in two steps:

1.Export the Report to ODBC Table

2.Send the Table to Email in your application code.

Example

Exporting to File in ODBC-Table 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;

VCL Reference

280

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