Avoid repeating column header in JRXML

孤人 提交于 2019-12-31 19:20:11

问题


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 report using JRXML and Jasper?


回答1:


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.




回答2:


Set The following parameter into your java code if your using java to fill the report:

parameters.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.TRUE);



回答3:


In jasper report tag put
isIgnorePagination="true"




回答4:


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."




回答5:


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.




回答6:


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).




回答7:


Create a dummy group and use the Group Footer Band.. That did the trick for me since the summary band was already used..




回答8:


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.




回答9:


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.




回答10:


We can use below line also to avoid repeated columnHeader



来源:https://stackoverflow.com/questions/7347020/avoid-repeating-column-header-in-jrxml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!