Jasper Reports subreport on a new page

2019-06-27 20:56发布

问题:

I have a jasper report that consists of 6 subreports. Each of these subreports has its own title section. Now I need each report to start on the new page. I tried adding page breaks but it did not work for me.

While researching the problem I cam across a trick to set isTitleNewPage to true at http://www.dzone.com/snippets/jasperreports-subreport-new. So I added the attribute isTitleNewPage="true" to all the subreports, but now the subreport's Title remains on the previous page and Details and Summary of that subreport are being displayed on a new page.

How can i solve this problem??

回答1:

I had the same problem that the title remains on the previous page.

But I have a solution:

  • put the stuff from the title in the "page header" band
  • set isTitleNewPage="true"
  • add a Integer variable to the subreport with the initial value 0
  • inkrement type "page"
  • expression $V{vari} + 1
  • print when expression of the page header is $V{vari} == 0

Now u have your title stuff on a new page, but only one time.



回答2:

My solution to this problem is to add every Subreport in a separate "Detail band" and then set the Band height to the biggest possible value (right click on the "Detail X Band" => "Maximize Band Height"). Between bands could be printed some blank pages, but that is not a big problem in my case.



回答3:

In the initial tag:

<jasperReport

put:

isTitleNewPage="true"



回答4:

Simplest solution is to set runToBottom flag to true in subreport tags.

<subreport runToBottom="true">

This forces the subreport to fill the whole page, so the next subreport will start on a new page.

Flag isTitleNewPage won't do the trick because like you noticed, it will split the subreport's title band with the rest of the subreport content (unless you're using a blank title band).