How to create jrxml for sub reporting

纵饮孤独 提交于 2019-12-02 07:34:46

问题


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.


回答1:


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}.




回答2:


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>


来源:https://stackoverflow.com/questions/5740654/how-to-create-jrxml-for-sub-reporting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!