Harshad Kadam
Harshad Kadam

Reputation: 181

iReport make multiple reports in one resultset

I am using a query in jrxml and it has resultset like below:

name - description - value

xyz ----- desc1 ------- 2
xyz ----- desc2 ------- 55
xyz ----- desc3 ------- 54
pqr ----- desc1 ------- 6
pqr ----- desc2 ------- 44
pqr ----- desc3 ------- 77

the name goes in header part and rest of the data goes in table part. i want new page of report for each different name. How to do in iReport 3.7.5?

Upvotes: 0

Views: 1064

Answers (1)

Alex K
Alex K

Reputation: 22867

You can create group for the name field and set isStartNewPage property for the Group band.

The sample:

<queryString>
    <![CDATA[SELECT name, description, value FROM table_name ORDER BY name]]>
</queryString>
<field name="name" class="java.lang.String"/>
<field name="description" class="java.lang.String"/>
<field name="value" class="java.lang.Integer"/>
<group name="nameGroup" isStartNewPage="true">
    <groupExpression><![CDATA[$F{name}]]></groupExpression>
    <groupHeader>
        <band height="20">
            <textField>
                <reportElement x="0" y="0" width="200" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA["Name: " + $F{name}]]></textFieldExpression>
            </textField>
        </band>
    </groupHeader>
</group>
<detail>
    <band height="20" splitType="Stretch">
        <textField>
            <reportElement x="0" y="0" width="100" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$F{description}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="100" y="0" width="100" height="20"/>
            <textElement/>
            <textFieldExpression><![CDATA[$F{value}]]></textFieldExpression>
        </textField>
    </band>
</detail>

Upvotes: 1

Related Questions