FastReport 下如何透過動態產生欄位設計報表 |
尚未結案
|
thomas0728
中階會員 發表:112 回覆:260 積分:89 註冊:2002-03-12 發送簡訊給我 |
|
likush
高階會員 發表:5 回覆:235 積分:103 註冊:2002-10-08 發送簡訊給我 |
|
chinyu
高階會員 發表:12 回覆:157 積分:153 註冊:2002-06-14 發送簡訊給我 |
引言: 各位大大好: 大為我 Client 端的程式的DataSet 是動態產生的,所以在設計 FastReport 時無法帶必欄位資料,請問我如在動產生欄位的情形下設計報表,是否有範例可參考 謝謝 如果愛情也有味覺 那麼 有沒有ㄧ種愛 微微泛酸 不太苦澀 有點甜密 嚐起來的滋味讓人想起幸福 Thomas Chiou這是fr3.0手冊中完全coding的範例,fr2.x應差不多,我大部份都是部份coding,比較不用麻煩。 Creating a report form from code As a rule, you will create most reports using the designer. Nevertheless, in some cases (for example, when the report’s form is unknown) it is necessary to create a report manually, from code. To create a report manually, one should perform the following steps in order: - clear the report component - add data sources - add report’s page - add bands on a page - set bands’ properties, and then connect them to the data - add objects on each band - set objects’ properties, and then connect them to the data Let us examine creation of a simple report of the «list» type. Assume that we have the following components: frxReport1: TfrxReport and frxDBDataSet1: TfrxDBDataSet (the last one is connected to data from the DBDEMOS, the «Customer.db» table). Our report will contain one page with the «Report Title» and «Master Data» bands. On the «Report Title» band there will be an object with the "Hello FastReport!" text, and the «Master Data» one will contain an object with a link to the "CustNo" field. var Page: TfrxReportPage; Band: TfrxBand; DataBand: TfrxMasterData; Memo: TfrxMemoView; { clear a report } frxReport1.Clear; { add a dataset to the list of ones accessible for a report } frxReport1.DataSets.Add(frxDBDataSet1); { add a page } Page := TfrxReportPage.Create(frxReport1); { create a unique name } Page.CreateUniqueName; { set sizes of fields, paper and orientation by default } Page.SetDefaults; { modify paper’s orientation } Page.Orientation := poLandscape; { add a report title band} Band := TfrxReportTitle.Create(Page); Band.CreateUniqueName; { it is sufficient to set the «Top» coordinate and height for a band } { both coordinates are in pixels } Band.Top := 0; Band.Height := 20; { add an object to the report title band } Memo := TfrxMemoView.Create(Band); Memo.CreateUniqueName; Memo.Text := 'Hello FastReport!'; Memo.Height := 20; { this object will be stretched according to band’s width } Memo.Align := baWidth; { add the masterdata band } DataBand := TfrxMasterData.Create(Page); DataBand.CreateUniqueName; DataBand.DataSet := frxDBDataSet1; { the Top coordinate should be greater than the previously added band’s top height} DataBand.Top := 100; DataBand.Height := 20; { add an object on master data } Memo := TfrxMemoView.Create(DataBand); Memo.CreateUniqueName; { connect to data } Memo.DataSet := frxDBDataSet1; Memo.DataField := 'CustNo'; Memo.SetBounds(0, 0, 100, 20); { adjust the text to the right object’s margin } Memo.HAlign := haRight; { show the report } frxReport1.ShowReport; |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |