P
a
ge:
1
FastReport 3.0
Programmer's
manual
Copyright (c) 1998-2004, Fast Reports, Inc.
P
a
ge:
2
Table of Contents
FastReport components review................................................................................................4
TfrxReport......................................................................................................................4
TfrxDBDataset..............................................................................................................11
TfrxUserDataset............................................................................................................11
TfrxDesigner.................................................................................................................12
TfrxPreview..................................................................................................................13
TfrxBarcodeObject.......................................................................................................15
TfrxOLEObject.............................................................................................................15
TfrxChartObject............................................................................................................15
TfrxRichObject .............................................................................................................15
TfrxCrossObject............................................................................................................15
TfrxCheckBoxObject.....................................................................................................15
TfrxGradientObject........................................................................................................15
TfrxDialogContols.........................................................................................................15
TfrxBDEComponents ....................................................................................................15
TfrxADOComponents....................................................................................................16
TfrxIBXComponents .....................................................................................................16
Working with TfrxReport component
.....................................................................16
Loading and saving a report (載入及儲存報表).....................................................................16
Designing a report (設計報表)..............................................................................................16
Running a report (執行報表).................................................................................................17
Previewing a report (預覽報表).............................................................................................17
Printing a report (列印報表)..................................................................................................18
Loading and saving a finished report (載入及除存已完成的報表)..........................................18
Exporting a report (匯出報表)...............................................................................................18
Creating a custom preview window (建立客製化預覽視窗)...................................................18
Building a composite report (batch printing) (建立複合式報表(批次列印)).............................19
Numbering of pages in a composite report..............................................................................19
Combination of pages in a composite report ...........................................................................19
P
a
ge:
3
Interactive reports(交談式報表)............................................................................................19
Access report objects from a code(存取報表物件程式碼)......................................................21
Creating a report form from a code(使用程式碼建立報表).....................................................21
Creating a dialogue form from a code(建立對話視窗程式碼).................................................23
Modifying report page’s properties (修改報表頁面屬性).......................................................24
Report construction with the help of a code ............................................................................25
Printing an array(列印陣列)..................................................................................................27
Printing a TStringList(
列印
TStringList)................................................................................27
Printing a file .......................................................................................................................28
Printing a TStringGrid ..........................................................................................................28
Printing TTable and TQuery..................................................................................................28
Working with a list of variables .............................................................................................29
Creating a list of variables(建立變數清單)............................................................................30
Clearing a list of variables(清除所有變數)............................................................................30
Adding a category(新增變數分類)........................................................................................31
Adding a variable(新增變數)................................................................................................31
Deleting a variable(刪除變數)...............................................................................................32
Deleting a category(刪除變數類別)......................................................................................32
Modifying the variable’s value(修改變數的值)......................................................................32
Working with styles..............................................................................................................32
Creation of style sets.............................................................................................................35
Modifying/adding/deleting a style ..........................................................................................36
Saving/restoring a set............................................................................................................37
Clear report styles.................................................................................................................37
Styles library creation ...........................................................................................................37
Displaying a list of style sets, and application of a selected style..............................................37
Modification/adding/deleting of a styles set............................................................................38
Saving and loading a styles library( 儲存及載入樣式庫)........................................................38
P
a
ge:
4
FastReport components review
FastReport包含許多元件供報表建立、修改、匯出不同的格式及強化報表功能,讓
我們探究每一個 FastReport 元件盤上的元件。
TfrxReport
此為最主要的報表元件,一個 TfrxReport元件組成乙份報表。在設計時期,雙擊此
元件可呼叫報表設計器(Report Designer),此元件擁有所有載入、儲存、設計及檢視報表必
須的屬性及方法。讓我們檢查 TfrxReport 提供的方法:
procedure Clear;
清除報表
function LoadFromFile(const FileName: String; ExceptionIfNotFound:
Boolean = False): Boolean;
從給予的檔案名稱載入報表。假如第二個參數等於 “True”且檔案不存在,將產生例外狀
況,假如檔案載入成功,傳回值為”True”。
procedure LoadFromStream(Stream: TStream);
從串流(stream)載入報表。
procedure SaveToFile(const FileName: String);
儲存報表至指定的檔案名稱。
procedure SaveToStream(Stream: TStream);
儲存報表至串流(stream)。
procedure DesignReport;
呼叫報表設計環境。報表設計環境將嵌入在你的專案(要執行此功能,只要在 uses 子句加
入 frxDesign 單元或在專案加入“TfrxDesigner”元件)。
procedure ShowReport(ClearLastReport: Boolean = True);
開始製作報表並將輸出結果顯示在預覽視窗。假如“ClearLastReport”參數等於“False”,報
表將會加入至前一個報表的後面,否則前一個建立的報表會被清除(預設值)。
function PrepareReport(ClearLastReport: Boolean = True): Boolean;
開始製作報表但沒有顯示預覽視窗。參數指定方式與“ShowReport”方法(method)相同。假
如報表建構成功,此函數傳回“True”。
procedure ShowPreparedReport;
顯示先前使用“PrepareReport”所建立的報表。
procedure Print;
列印報表。
procedure Export(Filter: TfrxCustomExportFilter);
使用指定的匯出過濾器(export filter)匯出報表內容。
P
a
ge:
5
因為下列的方法只提供一種服務,在大部份的情況之下,你並不須要使用他們。在
增強 FastReport 的報表功能方面,他們可能是很有用的。例如,當撰寫客製化的報表元件
時。
function
Calc(
const
Expr:
String
): Variant;
計算“Expr”運算式並傳回結果。
function GetAlias(DataSet: TfrxDataSet): String;
傳回指定資料集(data set)的別名。
function GetDataset(const Alias: String): TfrxDataset;
傳回指定別名(Alias)的資料集。
procedure DoNotifyEvent(Obj: TObject; const EventName: String);
執行連接至”Obj”物件的“EventName”事件處理程序。
procedure DoParamEvent(const EventName: String; var Params:
Variant);
以任意的參數型態執行 “EventName”的事件處理程序。
procedure GetDatasetAndField(const ComplexName: String; var
Dataset: TfrxDataset; var Field: String);
解析“ComplexName”複合名稱(以 DataSet.”Field”表示),並傳回參照的資料集及欄位名稱。
procedure GetDataSetList(List: TStrings; OnlyDB: Boolean = False);
從 List 參數傳回報表可用的資料集清單,假如第二個參數為 True,僅傳回連接到資料庫的
資料集。
procedure AddFunction(const FuncName: String; const Category:
String = ''; const Description: String = '');
加入使用者自定函數至報表的函數清單。詳細資訊請參閱“The functions’ list extension” 乙
章。
TfrxReport 元件擁有下列屬性:
property EngineOptions: TfrxEngineOptions;
與 FastReport引擎相關的屬性集合。
property IniFile: String;
儲存 fastReport 環境變數設定的檔案或註冊基碼的名稱。
property Preview: TfrxCustomPreview;
連結至“TfrxPreview”元件,完成的報表將顯示於此元件上。假如此屬性空白,報表將顯示
於標準的預覽視窗。請見“Custom preview windows creating”乙章。
评论1