views:

1360

answers:

2

Hi! I have a Jasper Report and I want to create for this report a cover page. The cover page must contain some information coming from the DB, like Company name, etc. I am trying to do this using a subreport but I didn't succeed. I've created a main report which contains first the cover page as a subreport and then the whole report as a second subreport. I got an empty report.

My second try was to put inside the main report the cover page as a subreport but this didn't work as well.

Any hint how to do this?

Thanks a lot in advance.

+2  A: 

Directory Discourse

Setting up the subreport is not trivial using Jasper Reports. There are at least two ways to tell a master report where to find sub-reports.

  1. Provide a value for the SUBREPORT_DIR parameter.
  2. Place the subreports within the CLASSPATH.

For solution 1, determine the absolute directory of the master report location at run time. Then, place subreports in relative directories under the master report. Finally, tell the master report the absolute path to the subdirectory containing the subreports.

I have not used solution 2.

Parameterized Master

Consider parameterizing the master report, instead of creating subreports.

  1. Add a list of parameters to the report.
  2. Drag the parameters onto the report header.

If you only have one report, but want to use a different logo (and company name, styling, and so forth), then use parameters to configure the look and feel.

Subreport Usage

I find it useful to create subreports when the queries for the data are nearly the same, but need to group the data in slightly different ways. The master report contains everything that is common (showing input parameters -- so that the report can be recreated, headings, company name, user name, time stamp, page number, and so on), and the subreports focus on the differences. Often, the subreports will overlap and only be executed depending on the value of an input parameter.

Dave Jarvis
Thanks for your answer. I've parameterized the master and I got it running. My approach is the following: I've generated an empty report. I've added the cover page as a subreport. Now I want to add chapters, to the main. I don't know in which band should I add them. I am always getting an errorError filling print... Band height validation for subreport "report1" failed in the current page context (height = 842, top margin = 40, bottom margin = 40any idea how to bind many subreports into a main report?
Luixv
Ask at the iReport forum. http://jasperforge.org/
Dave Jarvis
A: 

Add them to the summary band, you may even chose to have that on a different page. Than on that subreport that you just added, at his summary band you can put another one, and on his, another one and so you go. You can have infinite reports binded together.

Eduardo Rodrigues