Jump to content

How to fill the subreport within the subreport?


Recommended Posts

Hi Guys,

I have scenario where MainReport has subreport1 and subreport1 has subreport2? Able to display the value till the subreport1 level but not able to print the subreport2 under the subreport1 :(

I am struggling from last 4 days. 

MainReport-->SubReport1--> SubReport2. 

I have to use XMLDataSource. Issue with subreport1-->subreport2 value coming null.


InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xmlString));
Document document = db.parse(is);
reportParams.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, "dd-MMM-yyyy");
reportParams.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, "#,##0.##");
reportParams.put(JRXPathQueryExecuterFactory.XML_LOCALE, Locale.ENGLISH);
reportParams.put(JRParameter.REPORT_LOCALE, Locale.US);


JasperReport subReport1= (JasperReport) JRLoader
+ "Reports/subReport1.jasper");
reportParams.put("SUBREPORT1", subReport1);
/* subreport2*/ 
JasperReport subReport2 = (JasperReport) JRLoader
.getRealPath("/") + "Reports/subreport2.jasper");
reportParams.put("SUBREPORT2", tradeDetailsSubReport);
/*Main Report*/
JasperPrint jasperPrintReport = JasperFillManager.fillReport(request
+ "Reports/main.jasper", reportParams);
In the main.jasper
<parameter name="SUBREPORT1" class="net.sf.jasperreports.engine.JasperReport"/>
In the subreport1.jasper
<parameter name="SUBREPORT2" class="net.sf.jasperreports.engine.JasperReport"/>

Passing the same "XML_DATA_DOCUMENT" as parameter in the subQuery.

Report is generated using the JasperStudio with the dummy xmlDataSource by passing harcoding the name of the subreport file name.

Please let me know , am i doing wrong, seems in Java i have to do change.please suggest




Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

  • 4 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...