neozerabbit Posted March 7, 2011 Share Posted March 7, 2011 When using sub report is it possible (and how) to use sub report jxml file instead of ".jasper" ? Link to comment Share on other sites More sharing options...
neozerabbit Posted March 9, 2011 Author Share Posted March 9, 2011 ? Link to comment Share on other sites More sharing options...
szaharia Posted March 9, 2011 Share Posted March 9, 2011 Hi,The subreportExpression always expects a JasperReport object value. If you need to start from a jrxml file, you have to compile it first, to get a JasperReport object:<subreportExpression class="net.sf.jasperreports.engine.JasperReport"> <![CDATA[net.sf.jasperreports.engine.JasperCompileManager.compileReport("<path_to_jrxml_file_here>")]]></subreportExpression>Hope this helps,sanda Link to comment Share on other sites More sharing options...
neozerabbit Posted March 10, 2011 Author Share Posted March 10, 2011 Thanks. It's interesting. It works if I put the complete absolute file path but no the "SUBREPORT_DIR" + xxxx.jrxml file.I don't know why because there is no problem when I use the xxx.jasper file.Post Edited by neozerabbit at 03/10/2011 10:08 Link to comment Share on other sites More sharing options...
szaharia Posted March 10, 2011 Share Posted March 10, 2011 Could you post the jrxml source here? Usually the subreport expression process with no problems the $P{} syntax.Thank you,sanda Link to comment Share on other sites More sharing options...
neozerabbit Posted March 10, 2011 Author Share Posted March 10, 2011 Your solution gave me an ideaIn Java : I load, compile a report and put it as parameter......InputStream inputStreamErrors = Thread.currentThread().getContextClassLoader().getResourceAsStream("Ib-Daily-Errors-Report.jrxml");JasperReport errorsReport = JasperCompileManager.compileReport(inputStreamErrors);.......Map<String, Object> ibReportParam = new HashMap<String, Object>();ibReportParam.put("errorsReport", errorsReport); In Main report : set a parameter "errorsReport" as "net.sf.jasperreports.engine.JasperReport"Do not check "Use as prompt"Set sub report as<subreport> <reportElement stretchType="RelativeToBandHeight" isPrintRepeatedValues="false" x="0" y="0" width="2530" height="100"/> <dataSourceExpression><![CDATA[$P{ib-report-errors-dataSource}]]></dataSourceExpression> <subreportExpression class="net.sf.jasperreports.engine.JasperReport"> <![CDATA[$P{errorsReport}]]> </subreportExpression></subreport>Post Edited by neozerabbit at 03/10/2011 10:07 Link to comment Share on other sites More sharing options...
szaharia Posted March 10, 2011 Share Posted March 10, 2011 Nice. A very good solution for the problem. :)Regards,sanda Link to comment Share on other sites More sharing options...
andreasX Posted December 5, 2013 Share Posted December 5, 2013 general solutions for this: http://stackoverflow.com/a/20374515/1915920 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now