jasper-reportssubreport

The subreport repeats itself in Detail band


I am new to JasperReports, basically I want to put a subreport in a mainreport.

The problem is that I put the subreport in the Detail band, so when I query a database that has multiple data the subreport will always repeat itself multiple times when I output the report to a pdf. I want a report that doesn't repeat itself regardless of how many data I have in the database that I connect with.

I have searched the Internet and the solutions is to add:

new Boolean($V{REPORT_COUNT}.intValue()==1)

in the print when expression attribute of the subreport, that does solve a part of my problem due to the fact that now my subreport only prints once but it still leaves some blank pages after my subreport is displayed.

So I assume it is still repeating itself but just doesn't print the data because of the expression that I added , people say that the nature of the detail band is supposed to work that way and that I shouldn't put the subreport in the detail band, but if I put it in some other band I get this error:

Error filling print... Subreport overflowed on a band that does not support overflow.

The error above will happen if I have a lot of data to the extent that it may take up more than a page.

How do I remove those blank pages? If I am not asking to put it in a detail band then what should I do? or what solutions are there?


Solution

  • The Detail band will be generated as many times as the number of records you have in your main dataSet(populated by the top-level query).

    If you want to keep the subreport in the Detail band, which is normal by the way, you can do one of these things:

    If you can move the subreport out of the Detail band, place it in a band that allows overflow like Title or Summary band. Then: