问题
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