How-To Java Reporting

Jasper Report: Print Column Footer only at the last page

Report designer mostly said it’s depended on the way you design the report, of course, it does but for some new or even some years report designers still need example, tips to help too.

Here, I take this kind of issue/solution that finally I could make it: “printing a signature footnote to the last table of the report” which is very common issue in most of report design, right?

Without going on, do you have any suggestion?

My case in short, I solved it by using “Column footer” band which is suppose to print it on every page at the end of the detail printed block.

To achieve this, at first, you need to understand the role of each band of the report design, what are they for? So, please check that first and I cannot explain each one here yet.

Solution so far:

  1. You can use Summary block
  2. You can play with Detail block to print the last page (also can do with below solution)
  3. Use Column footer band to print the last page
  4. Use Last Page Footer, can do easier but it will always print to the bottom of the page that will free a lot of space above it in some cases

My case, I cannot use Summary block as I need to printout some graphic so I did it with Column footer which I think much right for me as it will automatically manage its block to the bottom of each page so we just manage to allow it to print only the last page only.

A. Make column footer to be able floating next to the last content of the detail block by click on the report, on the right tick “Floating Column Footer

Or via XML code, main report block add attribute: isFloatColumnFooter="true"

B. Create a variable to identify current page number: $V{CURRENT_PAGE}

  • Variable name: CURRENT_PAGE
  • Value Class Name: java.lang.Integer (Integer)
  • Calculation: No Calculation Function
  • Expression: $V{PAGE_NUMBER}
  • Initial Value Express: Blank
  • Increment type: Page
  • Reset type: Page

C. You may try to manage the print expression on the block, I can tell you it won’t work as the variable that we created won’t calculate itself before its render, so don’t try on Print Expression as: $V{CURRENT_PAGE}.equals($V{PAGE_NUMBER})

D. To do it on each textfield as it has Evaluation time to handle the variable calculation, in our case, we need to place the textfield and manage how the text will display on Text field’s expression as example:

  1. Expression: $V{CURRENT_PAGE}.equals($V{PAGE_NUMBER}-1) ? "Signature":"" (I minus 1 as I skip a page, Summary)
  2. Evaluation time set to Auto
  3. On textfield’s appearance, tick Remove Line When Blank

You have to do that for all textfields you want to display on the block, result will be as expected.

Let’s me know if this would help you.

Remark on Environment: I am doing it on

  • Windows 10 Pro
  • Jasper Report Studio 6.10.0 (and I think other lower version also the same either on iReport)
  • Java 12 (also OK with Java 8)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.