1
votes

pals!

I have a very special requirements for my report. Let's look at report at first:

___________
|         |
| header  |
|         |
| row     |
| row     |
| row     |
| footer  |
| footer  |
|_________|

This is my typical page in perfect case with all rows, header and footer on same page. Sometimes I have too many rows for one page and my report looks like this:

__________
|        |
| header |
|        |
| row    |
| row    |
| row    |
| row    |
| row    |
|________|

__________
| row    |
| row    |
| row    |
| row    |
| row    |
| row    |
| row    |
| footer |
|________|

__________
| footer |
|        |
|        |
|        |
|        |
|        |
|        |
|        |
|________|

And I can't just insert splitter between last row and footer because my requirements is: - Headers page must have at least one row - Footers page must have at least one row

So, I can' find solution to this problem. My footer can be splitted in two pages. My footer can be without rows and this is very bad for printing XLS file. I can use PDF instesad of XLS, but I have same problems. Does anybody have ideas how to solve this problem?

-----=== UPDATE ===-----

So, mr. dada67 provides great solution. We can put group into document and group will do what we need with expression = '1' (Looks like we select all elements). But there are some update to my question.

What if my every row is and subreport with some rows inside? When I use group in master report, Jasper process my every subreport with all his rows as an single row. Can I force Jasper to think that single element is not an whole subreport element but a single row from subreport?

-----=== UPDATE 2 ===-----

So, solution is here. When you need to move last row of your last subreport to next page with some footer - you just need to create group inside subreport with espression = '1' (to gather all rows) and settings from correct answer from dada67. This force jasper to draw footer after every subreport, but you can hide footer in all subreports except last.

Thanks to dada67!

1
So you want one header and one footer in a report ?Lokesh Pandey
Yep. Many many rows, but exactly one footer (block with several lines) and exactly one headerfinnetrolle
you can make header and footer globalLokesh Pandey

1 Answers

2
votes

JasperReports 6.4.3 introduced two new group attributes called minDetailsToStartFromTop and preventOrphanFooter which are used to specify if group headers and footer need to be accompanied by one detail band (or more in the case of headers).

So you can create a group in the report with a constant expression, set the two attributes and use the group header and footer band(s).

As in

<group name="Group" minDetailsToStartFromTop="1" preventOrphanFooter="true">
    <groupExpression><![CDATA[1]]></groupExpression>
    <groupHeader>
        ...
    </groupHeader>
    <groupFooter>
        ...
    </groupFooter>
</group>