Overview
Flow Chart for Designing a Report
Effect of the First Report
The document introduces the main functions of FineReport by creating a report. Before creating a simple general report, you can first view the final effect of the report, based on which you can design the report.
This report consists of three parts:
Parameter panel: You can select the region through the drop-down box widget to query the corresponding data of the selected region.
Table:The sales volume of each product of each salesperson in the selected region is summarized.
Column chart: The data in the table is displayed in a column chart.
Procedure
Data Connection Creation
Data connection creation is meant to connect the FineReport designer to the database so that the report can read data from, write data into, and modify data in the database.
Open the designer. In the menu bar at the top, choose Server > Define Data Connection. In the Define Data Connection dialog box, it is shown that the designer connects to a built-in database (FRDemo) by default. Click Test Connection. The Successful Connection prompt pops up, indicating the connection between the database and the designer is successfully created.
Next, you can obtain data from the database for report designing.
Report Creation
1. Click File in the menu bar to choose a report type. Click the shortcut to create a blank general report directly, as shown in the following figure.
This document takes the creation of a general report as an example.
2. During report creation, the theme that the designer applies to created templates is used by default. In the theme, styles of the template, cell, and chart have been preconfigured. Therefore, during the report design, you can select Theme to directly apply styles of the theme. For details about the template theme, see Template Theme Management.
The default theme of a general report is Classic Light Gray. The theme name is displayed in the toolbar at the top of the report. Click the name to see the theme selection page Template Theme. In this example, Refresh Technology is selected.
Data Preparation
A dataset is the direct data source for report designing. Datasets can be classified into two types according to the application scope: server datasets and template datasets. For details about the differences between them, see Dataset.
In this example, Template Dataset is selected from the dataset management panel. Click , and click Database Query to create the database query ds1. Enter the SQL query statement: SELECT * FROM Sales_Volume to obtain all the data of the Sales_Volume table.
After dataset creation, check the obtained data on the dataset management panel, as shown in the following figure.
So far, the data preparation for the report has been completed. The report style will be designed in the following part.
Table Design
1. Set the headline.
Select cell A1 to cell D2, and click Merge Cells to merge the cells, as shown in the following figure.
Enter Regional Sales Overview as the report title. Choose Cell Attribute > Style > Style Setting on the attribute panel on the right. Choose Theme > Big title, as shown in the following figure.
Note: The styles here are from the selected Refresh Technology theme. If you want to modify the style of a specific cell individually, you can select Custom to make modifications. For details about modifying the theme style, see Template Theme Management.
2. Insert the slash.
As you can see in section "Effect of the First Report", a cell, in which the information of three table header fields is displayed and separated by slashes, is located in the upper left corner of the table.
After merging cells A3 and B3 and selecting the merged cell, click the Insert Slash button on the upper toolbar, and enter the text "Product | Salesperson | Region" in the text editing box in the pop-up Slash editing dialog box, as shown in the following figure.
Note: The vertical line ( | ) should be a half-width symbol. You can add spaces to adjust the display position of text.
Adjust the width and height of cell A3. Choose Cell Attribute > Style > Style Setting on the attribute panel on the right. Choose Theme > Small title, as shown in the following figure.
When the Small title style is applied, the font size of the cell is relatively large. You can click Custom to modify the font size. (All the other setting items will retain the styles in the theme.)
After the modification, the cell style is changed accordingly, as shown in the following figure.
3. Fill in the data.
Drag the data columns to be displayed from the dataset into the corresponding cells as needed, as shown in the following figure.
The cell expansion direction for a data column in a cell is vertical expansion by default. In this example, you need to set horizontal expansion for cell C3 where the Product data column is located.
Select cell C3, choose Cell Attribute > Expansion > Expansion Direction, and set the expansion direction to Horizontal, as shown in the following figure.
4. Calculate the total sales volume.
In this example, the sales volume of each salesperson is calculated horizontally. The sales volume of each product is calculated vertically.
Enter the table header, and enter Total Sales Volume in cell D3. Merge cell A5 and cell B5, and enter Total: in the merged cell.
Select cell C5, and insert the summation formula SUM(C4). C4 represents Sales_Volume. In this way, the total sales volume of each product can be calculated vertically. The shortcut button on the toolbar can be used to insert formulas.
The total sales volume of each salesperson should be calculated horizontally and displayed in cell D4. Insert the summation formula SUM(C4). Note that each cell is in the parent-child cell relationship, which means the value of a cell will be expanded or calculated along with the change in the value of its parent cell. For details, see Parent-Child Cell Setting.
In this example, the value of cell D4 should be calculated according to the Salesperson field. Specifically speaking, the left parent cell of cell D4 should be set to cell B4 where the Salesperson field is located, as shown in the following figure.
Insert SUM(D4) or SUM(C5) to cell D5 to calculate the sales volume of all products.
5. Set the styles of other cells.
Choose Cell Attribute > Style > Style Setting on the attribute panel on the right. Choose Theme > Header for the following cells: C3, D3, A4, B4, and A5. Choose Theme > Main text for the following cells: C4, D4, C5, and D5, as shown in the following figure.
6. Save the report. Click Pagination Preview to check how the report is displayed.
Parameter Design
By configuring parameters, you can add widgets for parameters on the parameter panel and bind widgets to report data. In this way, you can use parameters to query specified data. For details about parameters, see Parameter Introduction.
This section describes how to design parameters for a report.
1. Add template parameters.
In the menu bar, choose Template > Template Parameter. Add a parameter in the displayed dialog box for template parameter configuration. Double-click the parameter name to rename the parameter to Region. Set New York as the default value.
2. Configure the parameter panel.
Click the edit icon on the parameter panel to enter the parameter panel setting page. The widget setting panel on the upper right corner displays the parameters that have not been generated. Click Region or Add All to add the parameter to the parameter panel.
The following widgets are generated using the parameter: a label widget, a custom widget whose type is not set, and a query button widget. Deselect Display Nothing Before Query, as shown in the following figure.
3. Configure widgets.
Click the edit icon of the custom widget. Select the drop-down box widget, as shown in the following figure.
4. Bind data to the widget.
In this example, you need to query the sales data of region A or B selected from the drop-down list. Therefore, the bound data dictionary should correspond to the field information of New York and California.
Select the drop-down box widget. Select Attribute on the widget setting panel on the right. Click the edit icon of the data dictionary. Set Database Table as the type, Sales_Volume as the dataset, and Region as the actual and display values of the column name.
5. Select para on the parameter panel to configure its attributes and styles. Deselect Display Nothing Before Query. Set Display Position to Left, as shown in the following figure.
6. Set filter conditions for cells.
After setting the parameter panel, click in the middle of the interface to return to the table. Though the parameter widget is set up, the region-specified data in the table cannot be queried based on the parameters in the drop-down list yet. This is because the data in the dataset is from the database and the data in the table comes directly from the dataset. Therefore, you need to set data filtering conditions for the table.
Double-click cell A4. In the Data Column pop-up dialog box, click Filter, and add a common condition where the column name Region equals the parameter value of $Region. Choose Add > OK. In this way, the cell Region is bound to the parameter so that when $Region is selected from the drop-down list for query, only data of that region is displayed in cells, as shown in the following figure.
7. The linkage between the parameters and the table data has been established. Save the settings, and preview the effect.
Chart Design
Charts can present data more clearly to enhance the user experience of viewing reports. This example only briefly introduces the concept of charts. For details about charts, see Chart Introduction.
This example shows how to insert a column chart into the cells to clearly display the total sales of each product by each salesperson.
1. Insert a chart.
Merge cells A7 to D18, select the merged cell, and click the Insert Chart shortcut button in the toolbar on the top to insert a column chart, as shown in the following figure.
2. Bind chart data.
This example displays the graph based on cell data.
Select the chart, and choose Cell Element > Data on the right attribute panel. Set the data source to Cell Data, Category Name to =B4, Series to =C3, and Value to =C4. That is to say, the X axis of the chart represents Salesperson from cell B4, the series is Product from cell C3, and the values of the Y axis are Sales_Volime from cell C4, as shown in the following figure.
Note: When you configure Category Name, Series, and Value, an equal sign must be included. Otherwise, the cell will be treated as a string.
3. Set the chart style.
As the column chart is a graphical representation of the sales data of different regions, you do not need to set a title for the chart. You can choose Style > Title and deselect Show Title, as shown in the following figure.
Note: In this example, no other chart styles will be set. All style settings can just follow the theme.
4. Set the parent cells of the cells where the chart is located. In this example, the column chart does not need to be expanded and does not depend on the left or upper parent cells. You need to set Expansion Direction to No Expansion, and set both Left Parent Cell and Up Parent Cell to None, as shown in the following figure.
Note: In principle, you can just set Up Parent Cell to None here. However, for the convenience of memory, you are advised to set both parent cells to none.
So far, this report has been completed. The effects of the report on PC and the mobile terminal are displayed in the following part respectively.
Effect Display
PC
Save the report, and click Pagination Preview. The following figure shows the preview effect.
The report can be previewed on both the DataAnalyst app and the HTML5 terminal. The following figure shows the display effect.
Template Download
For details, you can download the template: First General Report.cpt.