Welcome

Welcome, thanks to look my blog

Saturday 9 January 2016

Constructing a cross-tab report

Constructing a cross-tab report


Now let's turn from theory to practice. We will construct a simple cross-tab report displaying employees’ salaries over four years. To do this we need the “crosstest” table, which is located in the FastReport “DEMOS\MAIN” folder. The table contains data like:

Name        Year        Salary
Ann        1999        3300
Ben        2002        2000
….

Create a new project in Delphi, place “TTable”, “TfrxDBDataSet” and “TfrxReport” components on the form and set their properties:

Table1:
DatabaseName = 'c:\Program Files\FastReport 4\Demos\Main'
TableName = 'crosstest.db'

the DatabaseName property, of course, must correspond to the path of your FastReport installation folder!

frxDBDataSet1:
DataSet = Table1
UserName = 'SimpleCross'

The “TfrxCrossObject” component _img169 from the FastReport component palette is used to design a cross-tab report. Just place it on the Delphi form, it does not need any properties to be changed. The “frxCross” unit, containing the cross-tab functionality, is added to the “uses” list when the Delphi application is compiled. 

Open the report designer. Firstly connect the data source using the “Report > Data…” menu item. Then select  the “DB cross-tab” object 159 from the designer's object toolbar and click on the design page to place the object there:

clip0017

All settings are made using the cross-tab editor. Open it by double-clicking on the object:

clip0032

Key to the items shown above:

1 – a drop-down list of available data sources
2 – the list of fields in the selected data source; the fields from this list can be dragged to the lists numbered 3, 4 or 5
3 – the list of fields which generate line (row) headers
4 – the list of fields which generate column headers
5 – the list of fields which generate table cells
6 – table structure preview
7 – structure options : display of titles, totals, etc

You can only use the mouse in this editor to make changes. For our example it is only necessary to drag fields from the list 2 to lists 3, 4 and 5 (in the diagram above). After that close the editor by clicking the ОК button. The cross-tab object now shows its structure:

clip0055


When the report is previewed you will see a table resembling this:

clip0153

sumber:https://www.fast-report.com/public_download/html/UserMan/index.html?construct_a_cross_report.htm

No comments:

Post a Comment