New page for every group in iReport

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-16 18:22:35

问题


I'm using iReport 5.6.0 and i want to create new page for each group.

For example i have table people_i_know:

Id| Name | State
1 | Tom  | friends
2 | Jim  | friends
3 | Mike | enemy
4 | Alex | friends
5 | Julie| enemy

My SQL should be like this:

SELECT Id,Name,State FROM people_i_know GROUP BY State;

And in this example iReport should give me two pages with detail band like this:

This should be on page 1.

1 | Tom  | friends
2 | Jim  | friends
4 | Alex | friends

And this should be on page 2.

3 | Mike | enemy
5 | Julie| enemy

How do i make that iReport make something like this?


回答1:


You do not need to group in query, just order them

SELECT Id,Name,State FROM people_i_know State ORDER BY State;

in jrxml

you will have a field relative to the State column

<field name="State" class="java.lang.String">
    <fieldDescription><![CDATA[]]></fieldDescription>
</field>

create a group on State with attribute isStartNewPage="true"

<group name="State" isStartNewPage="true">
    <groupExpression><![CDATA[$F{State}]]></groupExpression>
</group>

and now just put the fields you like to display in the detail band



来源:https://stackoverflow.com/questions/35067774/new-page-for-every-group-in-ireport

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