How to insert a page break in JasperReport

2020-05-26 05:30发布

问题:

I have a JasperReports template, with a filled detail band.

If I run the report, I have a page count of 27 (27 detail rows)

I want that detail row number 12 begins with a new page, so I have to insert a pagebreak after pagecount 11.

But I cannot find the element "pagebreak" - What is it called in Jasper?

The 2nd question:

Is it also possible to modify the format (font, size,....) of each detail-row?

For example: pagecount 1 - detail row is printed in sansSerif font size 10, pagecount 2 - detail row is printed in Serif font size 12 (bold) and so on.....

The 3rd question:

Is it possible to insert a tabulator in a string?

For example:

"Name:" + + "Hannes" + " \n" +

"City:" + " " + "New York"

-->so Hannes and New York should be placed on the same position (same space from the left side)

回答1:

Answer to your 1st question:

  • Drag Break to Detail band. Choose Page Break.
  • Set its property Print When Expression to $V{PAGE_COUNT}==11


回答2:

  1. It's called "Break". It's the first item in the tool palette in iReport.
  2. Sort of. Yes, you can use styled text and change fonts and sizes and colors dynamically. But generally the point of having a detail row is that all things in it look identical. To style the detail band differently on different pages you should be using subreports or tables.
  3. Yes. Use "\t". It's a recent feature, so you won't see it if your version is too old.