I'm using iReport 2.0.4 to export some data to excel from a java application.
My problem is my subreports are grouping under the top level report but I want them to be discrete reports. Currently it looks like this
Order
-Order Line 1
Receipts
-Receipt Line 1
-Receipt Line 2
Invoices
-Invoice Line 1
-Invoice Line 2
Order
-Order Line 2
Receipts
-Receipt Line 1
........
I want it to be 3 separate reports in one spreadsheet. Like this
Order
all Order lines
Receipts
all Receipt lines
Invoices
all Invoice lines
Currently I have the Orders as the master report and the Receipts and Invoices as subreports, dropped into the detail band Orders.
What is the best way to get this layout, if it's possible at all?
You can fill and compile three separate reports and then use JRPdfExporterParameter.JASPER_PRINT_LIST parameter for building the single report using code like this:
You can look at this sample for your JR version - 2.0.4 for more details.
You can add several datasets in iReport 4.x version to the single report. Every dataset may contain its own query. The list component can use its own dataset.
In this sample (build with iReport 4.5.1) I've placed 3 list components to the Title band:
The report's design is:
The result will be (via iReport preview):
In JasperReports 6.1.1 API the
JRPdfExporterParameter.JASPER_PRINT_LIST
andJRPdfExporterParameter.OUTPUT_STREAM
is Deprecated I add to @Alex K answer the current non deprecated metod:"First way. Using JasperReports API"
replace (deprecated code):
with