Avoid repeating column header in JRXML
How can I avoid the column name repeating in JRXML? Is there any attribute for avoiding having the column header in each page when generating a rep开发者_运维问答ort using JRXML and Jasper?
If the header will always be on a specific page (e.g. the first page), you can add
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>
to the band, which will make it only print on page 1. PAGE_NUMBER
is an inbuilt variable that is automatically incremented as the report is generated.
Set The following parameter into your java code if your using java to fill the report:
parameters.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.TRUE);
In jasper report tag put
isIgnorePagination="true"
Another option: http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JRParameter.html#IS_IGNORE_PAGINATION
"If set to true the report will be generated on one long page."
An easier option is to choose the "Table Header" to be used for the header instead of "Column Header".
I also faced same problem and that solution worked for me.
Is there any attribute for avoiding having the column header in each page when generating a report using JRXML and Jasper?
You can use isPrintInFirstWholeBand
property and move columns header to the Group Header
band (or Title
band if you have not group).
Create a dummy group and use the Group Footer Band.. That did the trick for me since the summary band was already used..
I tried:
params.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.TRUE);
But, I got a long page 1/1, that it is not easy to print without getting any row splitted in the half.
Instead, I choosed the second approach from iReport designer:
1-create new empty cells in Table Header.
2-Move the cells(Header Cells) from the Column Header to Table Header, bydragging one by one.
3-Delete the empty cells in the Column Header.
4-Design the new cells background by selecting them choosing Backcolor from properties, or selecting the column (table) to define style, choose table 1_CH
from properties.
I would just avoid using the column header whenever I can. For some reason group headers provide users with a lot more options and flexibility.
So even if I don't use groups in my report I create a "constant group" that uses a constant expression as groupExpression
and then use this group's header as the report's column header.
With a constant expression like true
the group never changes because it's independent from the data set. And because it never changes it not only won't ever be printed twice automatically, it will also provide the option to be reprinted on each page (among other options) by simply checking the checkbox in JasperSoft studio (or adding the corresponding attribute to the group tag).
The advantages over deactivating pagination or using a page dependent printWhenExpression
are:
- independent from the page number that the header appears on for the first time (a title page or dynamic content might push the first appearance to the second or third page)
- allows pagination (nice for exporting as PDF with page headers/footers)
- offers more options than standard column header
Downsides
- adds complexity to the report
Here is an example for a non-repeating constant group header definition in JRXML:
<group name="columnHeaderGroup" isReprintHeaderOnEachPage="false">
<groupExpression><![CDATA["a constant"]]></groupExpression>
<groupHeader>
<band height="20">
<!-- any column header content like Static Texts or Text Fields -->
</band>
</groupHeader>
</group>
Note that you could also simply remove isReprintHeaderOnEachPage="false"
as this the default behavior.
We can use below line also to avoid repeated columnHeader
精彩评论