Search code examples
jasper-reports

How to loop the printing of a subreport


I have a Java application that fills a jasper report, with many subreports each containing up to 20 dynamic fields, to print a pdf file.

I need to print one of my subreports more than one time: I take this information from Java. How can I loop the printing phase of this subreport, passing to JasperReports' report just the number of repetitions that I need?

Practically I have an array of n object and I want to add to my main report n subreports, each done more or less like this:

subreport_example.

I'm using Jaspersoft Studio 6.3.1.


Solution

  • If your suberport is inside the detail band, you could add multiple rows to your datasource. One for each "repetition" you want to have, so the subreport will be printed multiple times.