I have a scenario below.
I need to print an Invoice together with an acknowledgement letter. (Seperate for each customer)
Customer Invoice Date Amount
A1 INV001 01/01/2010 1000
A2 INV002 03/02/2010 2000
A1 INV003 03/02/2010 1500
Ineed to print as below
Acknowledgement (first Page)
Customer : A1
INV Date Amount
INV001 01/01/2010 1000
INV003 03/02/2010 1500
after this need to print the above invoices (001 and 003) on seperate pages (page 2 and 3)
Acknowledgement (Page 4)
Customer : A2
INV Date Amount
INV002 03/02/2010 2000
after this need to print the above invoice (002) on next page(page 5)
SO in total the file should be in 5 pages.
Can someone help..? Can subreports do this?
You do not need to use sub report to produce the report as per your design requirement. Please take a look at this wiki article for a sample report based on your requirement:
Yes this can be done with JasperReport with 1 page and the help of 1 table and 1 subreport.
Main query (dataset):
Here you should make a query and GROUP BY Customer. This way it returns X (is amount of customers) record, and the whole report is repeated X times.
Table on first page:
You have to define table on the first page. As parameter you should send the 'Customer' and then make a query for that tables that returns all the invoices of that parameter (Customer).
If you preview now, you'll see page 1 and page 4 (from your example)
Subreport on second page
Now you place a subreport on the second page. As parameter you give it 'Customer' as well, and you could use the same query: it returns the report as many times as there are records in teh result.
Good luck with it