I am new to JasperReports, basically I want to put a subreport in a mainreport
The problem is that I put the sub report in the Detail band, so when I query a databas
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:
$V{REPORT_COUNT}.intValue()==1
) directly on the Detail band, not on the subreport. Please note that this is just an ugly hack that may affect the report performance. Your main query still returns a lot of data that you don't use so you should consider the other options.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:
<jasperReport>
tag) so that all the other sections except the Detail get generated