How to create jrxml for sub reporting

2019-02-28 20:32发布

I want create a complex jrxml file to create PDF.

I want to put another jrxml in my jrxml file.

So.. my question is how to put one jrxml to another jrxml

My jrxml files are: salesreport.jrxml, financialreport.jrxml and report.jrxml

I want to put salesreport.jrxml and financialreport.jrxml to report.jrxml.

2条回答
Melony?
2楼-- · 2019-02-28 21:07

Usually you develop reports with iReport.

iReport has facilities for including subreports within reports (by dragging the subreport icon onto the master report page).

Note that JasperReports uses absolute paths for file references. I would recommend you set up parameters to your reports as follows:

$P{ROOT_DIR}
$P{SUBREPORT_DIR}

Give $P{SUBREPORT_DIR} a default value of $P{ROOT_DIR} + "subreports/".

At that point, you can pass the absolute path as $P{ROOT_DIR} into your report and then the subreports will be stored in a subdirectory called subreports, which is located in $P{ROOT_DIR}.

查看更多
Emotional °昔
3楼-- · 2019-02-28 21:22

Or use the JasperCompileManager class from within the master jrxml file to dynamically compile it.

<subreportExpression><![CDATA[JasperCompileManager.compileReport($P{SUBREPORT_DIR}+"/myFile.jrxml")]]></subreportExpression>
查看更多
登录 后发表回答