I. Overview
The feature of embedded master-sub report is to embed independent report template in cells. The embedded template is called "sub report", and the whole embedded sub report is called "master report".
The format of each sub report can be out of alignment, and the format of the sub table and the master table can also be out of alignment. The sub report can obtain the values in the master table. As shown in the figure below, the list of employee sales is as follows:
II. Examples
1. Making master report
1) design form
Create a new normal report and design the master table as shown in the figure below:
Note: adjust the line height according to the actual situation, otherwise only part of the data can be displayed.
2) Adding parameters
Click template > template parameters to add a parameter to the master table, double-click the parameter name to modify it to orderID, and query the order information and order details of an OrderID through the parameter.
3) add drop-down box widget
Click the edit parameter interface, click "add all", and generate components on the parameter pane. The parameter widget selects the drop-down box and finally adjusts the location of the component.
4) Setting widget default value
Select the "drop-down box widget", change the name to "OrderID", and the widget value defaults to the string "10008", that is, query 10008's information by default.
Click data dictionary settings and select the orders table in FRDemo database. The actual value and display value are both orderID.
2. Making subreport 1
1) Data preparation
Create a new normal report, create a new database query DS1, and the SQL query statement is: select * from ORDERS
where OrderID = ${OrderID}
The order information of the corresponding orderID can be found through the parameter ID.
2) Design form
The design table is as follows:
Save the report when finished.
3. Making subreport 2
1) Data preparation
Create a new normal report, create a new database query DS1, and the SQL query statement is:
select * from ordersdetail
where OrderID = ${OrderID}
Through the parameter "OrderID", the order details corresponding to the orderID can be found.
2) Design form
The design table is as follows:
Save the report when finished.
4. Embedded subreport
1) Open the master report, right-click cell B4 of the master report, and select cell element > insert sub report, as shown in the following figure:
2) In the pop-up Insert Sub Report dialog box, select the path of subreport 1. Add parameter OrderID (parameter name in sub report), whose value is formula $OrderID, as shown in the figure below:
3) Right click cell B7 of the master report and select cell element > insert subreport. In the pop-up insert sub report dialog box, select the path of subreport 2, as shown in the following figure:
5. Effect preview
Save the report and click page preview. The effect is as follows:
Note: mobile terminal does not support.
III. Template download
For completed templates, please refer to:
Main report:%fr_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\BasicApplication\Master.cpt
Subreport 1:%fr_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\BasicApplication\Sub1.cpt
Subreport 2:%fr_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\BasicApplication\Sub2.cpt
Click to download the template:
IV. Precautions
1. Cell boundary between embedded sub report and main report
1) Problem description
When setting a border in the cell of a subreport embedded in the main report, the subreport cannot be aligned with the left border of the cell in the preview effect, as shown in the following figure:
2) Cause analysis
Because the "cell attributes > style > alignment" of cells will automatically indent left and right by default, when previewing, the left boundary of the embedded sub report and the main report cells cannot be aligned. As shown in the figure below:
3) Solutions
Change the left and right indent of cell attributes > style > alignment to 0. The effect is as follows:
Note: it is not supported to automatically fill the whole cell in sub report.