{"id":1718,"date":"2010-09-15T01:00:57","date_gmt":"2010-09-14T19:30:57","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=1718"},"modified":"2016-12-19T15:16:58","modified_gmt":"2016-12-19T09:46:58","slug":"passing-parameters-to-sub-reports-in-jasper","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/passing-parameters-to-sub-reports-in-jasper\/","title":{"rendered":"Passing parameters to sub-reports in Jasper"},"content":{"rendered":"<p>In one of our recent project, we made quite a good use of Grails Jasper plugin (v-0.9.7) to generate reports in the form of PDFs and Excel sheets. The reports contain sub-reports, which in many cases, contain sub-reports again. The way to pass parameters to sub-reports at the deeper level is to use the following tag in the .jrxml file: &lt;subreportParameter&gt;<\/p>\n<p>\nIn the Grails Jasper plugin, the  Jasper controller searches for the &#8220;<strong>SUBREPORT_DIR<\/strong>&#8221; in the params when the request is forwarded to it. If it does not find any key named &#8220;SUBREPORT_DIR&#8221; in the params map, it initializes the variable SUBREPORT_DIR with the value of &#8220;<strong>jasperFilePath<\/strong>&#8221; i.e. the location where the Jasper&#8217;s .jasper and .jrxml files can be found. Now suppose you want to give seperate file location for your sub-reports, you can easily do this using the following code in the .jrxml file inside the <strong><\/strong> tag:<\/p>\n<blockquote>\n<div class=\"code\">\n<pre>\r\n\r\n   ...\r\n \r\n        \r\n \r\n  ...\r\n\r\n<\/pre>\n<\/div>\n<\/blockquote>\n<p>Note the value of &#8220;<strong>![CDATA[$P{SUBREPORT_DIR}]]<\/strong>&#8221; parameter can be passed as a parameter from the controller to the master report but afterwards you can make use of the  tag to pass on the information to the subsequent sub-reports to any level.<\/p>\n<p>For more information on the jasper .jrxml tags, please visit the following link here: <\/p>\n<p>Hope this helps !!<\/p>\n<p>&#8211; Abhishek Tejpaul<br \/>\nabhishek@intelligrape.com<br \/>\n[IntelliGrape Software Pvt. Ltd]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In one of our recent project, we made quite a good use of Grails Jasper plugin (v-0.9.7) to generate reports in the form of PDFs and Excel sheets. The reports contain sub-reports, which in many cases, contain sub-reports again. The way to pass parameters to sub-reports at the deeper level is to use the following [&hellip;]<\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":14},"categories":[1],"tags":[159,586,588,587],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1718"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=1718"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1718\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=1718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=1718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=1718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}