删除iReport中的重复页面

时间:2011-12-27 13:10:39

标签: jasper-reports ireport

我正在使用List组件iReport填充数据,但pdf有两页。第2页中的数据与第一页相同。我在db中有25条记录,我想在一个页面中填充。表格数据在pdf页面中不断重复。列表中是否有任何设置可以避免它?我将非常感谢您的大力帮助。

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="test" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <subDataset name="dataset1">
        <parameter name="ID" class="java.lang.Integer"/>
        <queryString>
            <![CDATA[select * from CALENDAR WHERE REGION=$P{ID} ]]>
        </queryString>
        <field name="ID" class="java.lang.Integer"/>
        <field name="NAME" class="java.lang.String"/>
        <field name="REGION" class="java.lang.Integer"/>
        <field name="YEAR" class="java.lang.Integer"/>
        <field name="HOLIDAY_NAME" class="java.lang.String"/>
        <field name="DATE_PICKER" class="java.sql.Date"/>
        <field name="APPLICABLE_FROM" class="java.sql.Date"/>
        <field name="APPLICABLE_TO" class="java.sql.Date"/>
    </subDataset>
    <parameter name="ID" class="java.lang.Integer"/>
    <queryString>
        <![CDATA[select * from USERS]]>
    </queryString>
    <field name="ID" class="java.lang.Integer"/>
    <field name="EMP_ID" class="java.lang.Integer"/>
    <field name="LEVEL_ID" class="java.lang.Integer"/>
    <field name="REG_DIV_ID" class="java.lang.Integer"/>
    <field name="PROFILE_ID" class="java.lang.Integer"/>
    <field name="FINANCE_ID" class="java.lang.Integer"/>
    <field name="NOMINEE_ID" class="java.lang.Integer"/>
    <field name="PASSPORT_ID" class="java.lang.Integer"/>
    <field name="PERSONAL_ID" class="java.lang.Integer"/>
    <field name="SALARY_ID" class="java.lang.Integer"/>
    <field name="STATUS" class="java.lang.Boolean"/>
    <field name="CREATE_DATE" class="java.sql.Timestamp"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <pageHeader>
        <band height="87">
            <image>
                <reportElement positionType="Float" x="52" y="38" width="123" height="47"/>
                <imageExpression class="java.lang.String"><![CDATA["/home/user/Desktop/image003.jpg"]]></imageExpression>
            </image>
            <image>
                <reportElement positionType="Float" x="453" y="30" width="62" height="55"/>
                <imageExpression class="java.lang.String"><![CDATA["/home/user/Desktop/image002.jpg"]]></imageExpression>
            </image>
        </band>
    </pageHeader>
    <columnHeader>
        <band splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="89" splitType="Stretch">
            <componentElement>
                <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="52" y="53" width="464" height="29"/>
                <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
                    <datasetRun subDataset="dataset1">
                        <datasetParameter name="ID">
                            <datasetParameterExpression><![CDATA[$P{ID}]]></datasetParameterExpression>
                        </datasetParameter>
                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    </datasetRun>
                    <jr:listContents height="29" width="464">
                        <textField>
                            <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="28" y="5" width="197" height="20"/>
                            <textElement/>
                            <textFieldExpression class="java.lang.String"><![CDATA[$F{HOLIDAY_NAME}+"  "]]></textFieldExpression>
                        </textField>
                        <line>
                            <reportElement x="0" y="27" width="464" height="1"/>
                        </line>
                        <line>
                            <reportElement x="0" y="1" width="1" height="28"/>
                        </line>
                        <line>
                            <reportElement x="463" y="0" width="1" height="28"/>
                        </line>
                        <line>
                            <reportElement x="225" y="0" width="1" height="28"/>
                        </line>
                        <textField>
                            <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="301" y="6" width="100" height="20"/>
                            <textElement/>
                            <textFieldExpression class="java.lang.String"><![CDATA[$F{DATE_PICKER}]]></textFieldExpression>
                        </textField>
                    </jr:listContents>
                </jr:list>
            </componentElement>
            <rectangle>
                <reportElement x="52" y="30" width="464" height="23" backcolor="#DD6626"/>
            </rectangle>
            <textField>
                <reportElement x="80" y="35" width="181" height="23"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA["HOLIDAYS LIST"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="353" y="35" width="124" height="23"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA["DATE"]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="35" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band splitType="Stretch"/>
    </summary>
</jasperReport>

2 个答案:

答案 0 :(得分:0)

http://www.youtube.com/watch?v=NRQLErOgiNA&context=C34dac3cADOEgsToPDskI7lC_sotZz31ifSF5Q9zxt

希望此链接有所帮助。同时将isRepeatedValue属性设为false。

答案 1 :(得分:0)

您的报告旨在为每个用户重复列表。如果那不是您想要的,那么您需要将主查询select * from USERS更改为仅返回单行的内容,或者您​​需要将List移动​​到不重复的波段(如标题或摘要)带)。