Jasper报告显示主报告两次

时间:2016-01-22 10:14:54

标签: java jasper-reports

我遇到了Jasper Reports的问题。主报告显示两次。

"主报告的页眉,列标题和列页脚正在重复"

主报告 report1.jrxml

<?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="report1" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isSummaryNewPage="true" uuid="05cbe1a2-52af-4ae3-85d7-489f334e34c9">
    <property name="ireport.zoom" value="0.9090909090909095"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="154"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA[".\\report\\"]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="rep" class="java.lang.String">
        <fieldDescription><![CDATA[rep]]></fieldDescription>
    </field>
    <field name="phone" class="java.lang.String">
        <fieldDescription><![CDATA[phone]]></fieldDescription>
    </field>
    <field name="poNo" class="java.lang.String">
        <fieldDescription><![CDATA[poNo]]></fieldDescription>
    </field>
    <field name="invoiceNo" class="java.lang.String">
        <fieldDescription><![CDATA[invoiceNo]]></fieldDescription>
    </field>
    <field name="balanceDue" class="java.lang.String">
        <fieldDescription><![CDATA[balanceDue]]></fieldDescription>
    </field>
    <field name="terms" class="java.lang.String">
        <fieldDescription><![CDATA[terms]]></fieldDescription>
    </field>
    <field name="project" class="java.lang.String">
        <fieldDescription><![CDATA[project]]></fieldDescription>
    </field>
    <field name="date" class="java.lang.String">
        <fieldDescription><![CDATA[date]]></fieldDescription>
    </field>
    <field name="payment" class="java.lang.String">
        <fieldDescription><![CDATA[payment]]></fieldDescription>
    </field>
    <field name="comapnyName" class="java.lang.String">
        <fieldDescription><![CDATA[comapnyName]]></fieldDescription>
    </field>
    <field name="shipTo" class="java.lang.String">
        <fieldDescription><![CDATA[shipTo]]></fieldDescription>
    </field>
    <field name="shipDate" class="java.lang.String">
        <fieldDescription><![CDATA[shipDate]]></fieldDescription>
    </field>
    <field name="total" class="java.lang.String">
        <fieldDescription><![CDATA[total]]></fieldDescription>
    </field>
    <field name="email" class="java.lang.String">
        <fieldDescription><![CDATA[email]]></fieldDescription>
    </field>
    <field name="via" class="java.lang.String">
        <fieldDescription><![CDATA[via]]></fieldDescription>
    </field>
    <field name="billTo" class="java.lang.String">
        <fieldDescription><![CDATA[billTo]]></fieldDescription>
    </field>
    <field name="FOB" class="java.lang.String">
        <fieldDescription><![CDATA[FOB]]></fieldDescription>
    </field>
    <field name="details" class="java.util.List">
        <fieldDescription><![CDATA[details]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="84" splitType="Stretch">
            <staticText>
                <reportElement x="472" y="0" width="83" height="31" forecolor="#999999" uuid="76a71858-b332-4ee7-ae62-0c43aaba61b1"/>
                <textElement>
                    <font size="24"/>
                </textElement>
                <text><![CDATA[Invoice]]></text>
            </staticText>
            <staticText>
                <reportElement x="372" y="44" width="68" height="20" forecolor="#999999" uuid="aa8af6f1-9210-4fa0-b511-0e31e120fe2f"/>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Date]]></text>
            </staticText>
            <staticText>
                <reportElement x="372" y="63" width="68" height="20" forecolor="#999999" uuid="c5250a2d-0332-4647-bf0f-230550a68cee"/>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Invoice #]]></text>
            </staticText>
            <textField>
                <reportElement x="0" y="0" width="125" height="42" uuid="cdad05bf-a301-43d9-ad5b-9e21d9dce90c"/>
                <textFieldExpression><![CDATA[$F{comapnyName}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="454" y="42" width="100" height="20" uuid="19e676e9-706e-4c44-8ce7-e9d059ac13f9"/>
                <textElement verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{date}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="454" y="61" width="100" height="20" uuid="e5e7687d-575e-47a7-b666-39003f217cb1"/>
                <textElement verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{invoiceNo}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="1" y="63" width="49" height="20" forecolor="#999999" uuid="c2c327b5-901c-46e4-b077-48783418d94d"/>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Email :]]></text>
            </staticText>
            <staticText>
                <reportElement x="2" y="44" width="48" height="20" forecolor="#999999" uuid="fb3b1d64-2ef2-42a9-aaf2-4e902645c2e5"/>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Ph No. :]]></text>
            </staticText>
            <textField>
                <reportElement x="50" y="43" width="100" height="20" uuid="b6d1f82b-1303-42a8-9009-5027436611e8"/>
                <textElement verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{phone}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="51" y="64" width="167" height="20" uuid="0b046514-f27a-46bc-aa77-8ca9b6ffa789"/>
                <textElement verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{email}]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <pageHeader>
        <band height="133" splitType="Stretch">
            <rectangle>
                <reportElement x="0" y="38" width="253" height="83" forecolor="#999999" uuid="bb565d12-1470-41f7-a1a6-c338464701e3"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </rectangle>
            <rectangle>
                <reportElement x="302" y="38" width="253" height="83" forecolor="#999999" uuid="4e31bbf5-b2f1-42e4-8ac6-822ac41b891a"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </rectangle>
            <rectangle>
                <reportElement x="0" y="18" width="253" height="20" backcolor="#666666" uuid="7990ef73-ff81-4270-976a-407278508ccd"/>
            </rectangle>
            <rectangle>
                <reportElement x="302" y="18" width="253" height="20" backcolor="#666666" uuid="97457fa4-f2de-4b15-a384-cc927269c67e"/>
            </rectangle>
            <staticText>
                <reportElement x="302" y="18" width="100" height="20" forecolor="#FFFFFF" uuid="878af07a-e999-401c-a809-6cb8c5553fd7"/>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Ship To]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="18" width="100" height="20" forecolor="#FFFFFF" uuid="a469d2a2-70fa-4351-8ee4-7eecddb5b789"/>
                <textElement verticalAlignment="Middle"/>
                <text><![CDATA[Bill To]]></text>
            </staticText>
            <textField>
                <reportElement x="0" y="40" width="159" height="81" uuid="a05438c8-1259-4532-91ad-041f62636945"/>
                <textFieldExpression><![CDATA[$F{billTo}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="302" y="40" width="170" height="81" uuid="7a4e52d9-b8c9-4e0a-97f9-3cd33ff2cc30"/>
                <textFieldExpression><![CDATA[$F{shipTo}]]></textFieldExpression>
            </textField>
        </band>
    </pageHeader>
    <columnHeader>
        <band height="49" splitType="Stretch">
            <rectangle>
                <reportElement x="90" y="4" width="90" height="20" forecolor="#999999" backcolor="#666666" uuid="e05b6a9a-f6a8-4a15-91ed-490b52fda77d"/>
            </rectangle>
            <rectangle>
                <reportElement x="240" y="4" width="90" height="20" forecolor="#999999" backcolor="#666666" uuid="d53a2ae0-ff6b-4b7d-8630-8884e5cd9357"/>
            </rectangle>
            <rectangle>
                <reportElement x="390" y="4" width="82" height="20" forecolor="#999999" backcolor="#666666" uuid="15d4e4ea-15c3-4017-9c22-b2d2ab0369cd"/>
            </rectangle>
            <rectangle>
                <reportElement x="330" y="4" width="60" height="20" forecolor="#999999" backcolor="#666666" uuid="ef581d51-61ec-48b4-8524-b4eabb541def"/>
            </rectangle>
            <rectangle>
                <reportElement x="180" y="4" width="60" height="20" forecolor="#999999" backcolor="#666666" uuid="2b050b2b-7faa-4407-a3ef-6ac294372b58"/>
            </rectangle>
            <rectangle>
                <reportElement x="0" y="4" width="90" height="20" forecolor="#999999" backcolor="#666666" uuid="8898c2aa-89ce-4744-a14b-e7b07164fe4a"/>
            </rectangle>
            <rectangle>
                <reportElement x="472" y="4" width="83" height="20" forecolor="#999999" backcolor="#666666" uuid="ea3d39fa-ab3b-489b-bb6f-8ee65ce2c7f9"/>
            </rectangle>
            <rectangle>
                <reportElement x="0" y="24" width="90" height="20" forecolor="#999999" uuid="ee5e90e6-f68c-4559-9e53-9ad981dcc6a9"/>
            </rectangle>
            <rectangle>
                <reportElement x="90" y="24" width="90" height="20" forecolor="#999999" uuid="6a53b333-2130-4685-a4a6-a2385ee7f8d9"/>
            </rectangle>
            <rectangle>
                <reportElement x="180" y="24" width="60" height="20" forecolor="#999999" uuid="40f731fe-1443-47ff-96c7-a8b5997ae642"/>
            </rectangle>
            <rectangle>
                <reportElement x="240" y="24" width="90" height="20" forecolor="#999999" uuid="2717e310-0f6a-46eb-94df-9adaf5154a47"/>
            </rectangle>
            <rectangle>
                <reportElement x="330" y="24" width="60" height="20" forecolor="#999999" uuid="eb5bc674-f32d-4da2-b72c-64344b8e738d"/>
            </rectangle>
            <rectangle>
                <reportElement x="390" y="24" width="82" height="20" forecolor="#999999" uuid="432c7470-a371-45b2-8c63-7783a655fc86"/>
            </rectangle>
            <rectangle>
                <reportElement x="472" y="24" width="83" height="20" forecolor="#999999" uuid="2f2e0445-4532-4019-82e6-7355e659b5c4"/>
            </rectangle>
            <staticText>
                <reportElement x="0" y="4" width="90" height="20" forecolor="#FFFFFF" uuid="482fa543-2143-4dad-af7a-23f39d2ff87a"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[P.O.No]]></text>
            </staticText>
            <staticText>
                <reportElement x="90" y="4" width="90" height="20" forecolor="#FFFFFF" uuid="482fa543-2143-4dad-af7a-23f39d2ff87a"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[Terms]]></text>
            </staticText>
            <staticText>
                <reportElement x="240" y="4" width="90" height="20" forecolor="#FFFFFF" uuid="482fa543-2143-4dad-af7a-23f39d2ff87a"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[Ship Date]]></text>
            </staticText>
            <staticText>
                <reportElement x="390" y="4" width="82" height="20" forecolor="#FFFFFF" uuid="482fa543-2143-4dad-af7a-23f39d2ff87a"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[FOB]]></text>
            </staticText>
            <staticText>
                <reportElement x="472" y="4" width="83" height="20" forecolor="#FFFFFF" uuid="482fa543-2143-4dad-af7a-23f39d2ff87a"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[Project]]></text>
            </staticText>
            <staticText>
                <reportElement x="180" y="4" width="60" height="20" forecolor="#FFFFFF" uuid="482fa543-2143-4dad-af7a-23f39d2ff87a"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[Rep]]></text>
            </staticText>
            <staticText>
                <reportElement x="330" y="4" width="60" height="20" forecolor="#FFFFFF" uuid="482fa543-2143-4dad-af7a-23f39d2ff87a"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[Via]]></text>
            </staticText>
            <textField>
                <reportElement x="0" y="24" width="90" height="20" uuid="3a64955b-2b08-4e01-8587-b07a7fd0acc5"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{poNo}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="90" y="24" width="90" height="20" uuid="19f9aa9b-2826-4838-b6cf-d41bb3f24731"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{terms}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="180" y="24" width="60" height="20" uuid="485c579a-19b6-4762-a825-80009f72c606"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{rep}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="240" y="24" width="90" height="20" uuid="25c59048-939d-4e6c-b3d2-437d480bd19c"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{shipDate}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="330" y="24" width="60" height="20" uuid="f434ef7a-3120-4fbb-94c3-a5fe13949c80"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{via}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="390" y="24" width="82" height="20" uuid="25e8c9a7-1d1b-4d9a-a4e1-3d2ab863bce3"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{FOB}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="472" y="24" width="82" height="20" uuid="5c6e4613-be05-4b92-a0a4-d884f5a9aaed"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{project}]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
    <detail>
        <band height="411" splitType="Stretch">
            <rectangle>
                <reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="280" height="411" forecolor="#999999" uuid="492062f2-702e-4686-bb86-87eb720989e8"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </rectangle>
            <rectangle>
                <reportElement stretchType="RelativeToBandHeight" x="280" y="0" width="75" height="411" forecolor="#999999" uuid="08d79370-45b8-4027-a3bb-d2fbfc039b7d"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </rectangle>
            <rectangle>
                <reportElement stretchType="RelativeToBandHeight" x="455" y="0" width="100" height="411" forecolor="#999999" uuid="08d79370-45b8-4027-a3bb-d2fbfc039b7d"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </rectangle>
            <rectangle>
                <reportElement x="0" y="0" width="280" height="20" forecolor="#999999" backcolor="#666666" uuid="0777872f-113b-419f-87be-2a8a2fbeed06"/>
            </rectangle>
            <rectangle>
                <reportElement x="280" y="0" width="75" height="20" forecolor="#999999" backcolor="#666666" uuid="711c33be-9f7e-46b3-8424-eeb363b5227a"/>
            </rectangle>
            <rectangle>
                <reportElement stretchType="RelativeToBandHeight" x="355" y="0" width="100" height="411" forecolor="#999999" uuid="08d79370-45b8-4027-a3bb-d2fbfc039b7d"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </rectangle>
            <rectangle>
                <reportElement x="355" y="0" width="100" height="20" forecolor="#999999" backcolor="#666666" uuid="0308bfa1-46a6-4ca6-9cdb-3683052b142f"/>
            </rectangle>
            <rectangle>
                <reportElement x="455" y="0" width="100" height="20" forecolor="#999999" backcolor="#666666" uuid="d5e86c87-49e3-4d41-b7eb-25fa541d3e5f"/>
            </rectangle>
            <staticText>
                <reportElement x="100" y="0" width="100" height="20" forecolor="#FFFFFF" uuid="54309634-1b86-40d7-89ef-b4e78315e7a0"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[Discription]]></text>
            </staticText>
            <staticText>
                <reportElement x="280" y="0" width="75" height="20" forecolor="#FFFFFF" uuid="54309634-1b86-40d7-89ef-b4e78315e7a0"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[Qty.]]></text>
            </staticText>
            <staticText>
                <reportElement x="355" y="0" width="100" height="20" forecolor="#FFFFFF" uuid="54309634-1b86-40d7-89ef-b4e78315e7a0"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[Rate]]></text>
            </staticText>
            <staticText>
                <reportElement x="455" y="0" width="100" height="20" forecolor="#FFFFFF" uuid="5f6ff87d-2a8e-434f-a63c-551b3d17afbe"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <text><![CDATA[Amount]]></text>
            </staticText>
            <subreport>
                <reportElement isPrintRepeatedValues="false" x="-13" y="7" width="552" height="0" isRemoveLineWhenBlank="true" uuid="ea64266a-a37f-401b-878e-87b3e90ffc39">
                    <printWhenExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()==1)]]></printWhenExpression>
                </reportElement>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{details})]]></dataSourceExpression>
                <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "report2.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
    <columnFooter>
        <band height="66" splitType="Stretch">
            <rectangle>
                <reportElement x="455" y="0" width="100" height="20" forecolor="#999999" uuid="7f161bbb-686f-4445-9c5c-467676eba6a3"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </rectangle>
            <rectangle>
                <reportElement x="455" y="19" width="100" height="20" forecolor="#999999" uuid="4e527fb2-8675-435e-8b4d-7c961d4c29f2"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </rectangle>
            <rectangle>
                <reportElement x="455" y="38" width="100" height="20" forecolor="#999999" uuid="43808665-2209-4651-9088-9eacbbb65a23"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </rectangle>
            <staticText>
                <reportElement x="354" y="0" width="100" height="20" forecolor="#666666" uuid="9f5c9048-3f63-4473-ba66-31c0ab622c84"/>
                <text><![CDATA[Total]]></text>
            </staticText>
            <staticText>
                <reportElement x="354" y="19" width="100" height="20" forecolor="#666666" uuid="9f5c9048-3f63-4473-ba66-31c0ab622c84"/>
                <text><![CDATA[Payment / Credits]]></text>
            </staticText>
            <staticText>
                <reportElement x="354" y="38" width="100" height="20" forecolor="#666666" uuid="9f5c9048-3f63-4473-ba66-31c0ab622c84"/>
                <text><![CDATA[Balance Due]]></text>
            </staticText>
            <textField>
                <reportElement x="455" y="0" width="100" height="20" uuid="406b5e46-d652-4d19-8984-6221c4c8e0eb"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{total}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="454" y="18" width="100" height="20" uuid="3762bd55-b553-41b4-8827-f121c517f382"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{payment}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="455" y="39" width="100" height="20" uuid="e4d6d166-8b9b-44c2-95ab-6fafbdcf8e74"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{balanceDue}]]></textFieldExpression>
            </textField>
        </band>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

SubReport report2.jrxml

<?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="report2" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a160fe89-1f2e-4ebd-ac9f-54a52fbfb2a9">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="amount" class="java.lang.String">
        <fieldDescription><![CDATA[amount]]></fieldDescription>
    </field>
    <field name="rate" class="java.lang.String">
        <fieldDescription><![CDATA[rate]]></fieldDescription>
    </field>
    <field name="qty" class="java.lang.Integer">
        <fieldDescription><![CDATA[qty]]></fieldDescription>
    </field>
    <field name="discription" class="java.lang.String">
        <fieldDescription><![CDATA[discription]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band splitType="Stretch"/>
    </title>
    <pageHeader>
        <band splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="23" splitType="Stretch">
            <textField>
                <reportElement x="346" y="2" width="99" height="20" uuid="49ba1132-7081-41f9-8ea5-e40f4f2dbc95"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{rate}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="271" y="2" width="75" height="20" uuid="c21f8d6b-f465-453e-8507-680634673172"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{qty}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="446" y="2" width="100" height="20" uuid="a5a2c393-9514-45f1-aad4-cae98e8f5039"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{amount}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="1" y="2" width="280" height="20" uuid="2a5d5e0a-9b99-417c-b33a-74ec798cf3b3"/>
                <textFieldExpression><![CDATA[$F{discription}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band splitType="Stretch"/>
    </summary>
</jasperReport>

主报告工厂类 InvoiceFactory.java

public class InvoiceFactory {
public static Collection getInvoiceList(long InvoiceID, String Company, int ClientType) {
        Vector tblInvoiceTamplates = new Vector();
        String sql
                = "select"
                + " bca_company.CompanyID,bca_company.Name,bca_company.Address1,bca_company.Address2,bca_company.City,bca_company.State,bca_company.Phone1,bca_company.Email,"
                + " bca_invoice.InvoiceID,bca_invoice.OrderNum,bca_invoice.RefNum,bca_invoice.ClientVendorID,bca_invoice.CompanyID,bca_invoice.Total, bca_invoice.Balance, bca_invoice.DateAdded,bca_invoice.DateConfirmed,bca_invoice.ShippingMethod,"
                + " bca_clientvendor.Name,bca_clientvendor.FirstName,bca_clientvendor.LastName,bca_clientvendor.Address1,bca_clientvendor.Address2,bca_clientvendor.City,bca_clientvendor.State,bca_clientvendor.Country,bca_clientvendor.Phone,bca_clientvendor.Email,bca_clientvendor.CVTypeID,"
                + " storage_shippingaddress.Name,storage_shippingaddress.FirstName,storage_shippingaddress.LastName,storage_shippingaddress.Address1,storage_shippingaddress.Address2,storage_shippingaddress.City,storage_shippingaddress.State,storage_shippingaddress.ZipCode,storage_shippingaddress.Country,"
                + " bca_paymenttype.Name,"
                + " bca_term.Name,"
                + " bca_salesrep.Name"
                + " from"
                + " (((((bca_invoice INNER JOIN bca_company ON bca_invoice.CompanyID = bca_company.CompanyID) "
                + " INNER JOIN bca_clientvendor ON bca_invoice.ClientVendorID = bca_clientvendor.ClientVendorID)"
                + " INNER JOIN storage_shippingaddress ON bca_invoice.ShippingAddrID = storage_shippingaddress.AddressID)"
                + " INNER JOIN bca_paymenttype ON bca_invoice.PaymentTypeID = bca_paymenttype.PaymentTypeID)"
                + " INNER JOIN bca_term ON bca_invoice.TermID = bca_term.TermID)"
                + " INNER JOIN bca_salesrep ON bca_invoice.SalesRepID =  bca_salesrep.SalesRepID"
                + " where (((bca_company.CompanyID) =" + ConstValue.companyID + ")"
                + " and ((bca_invoice.OrderNum) = " + InvoiceID + ")"
                + "and ((bca_clientvendor.CVTypeID) = " + ClientType + "))";
        Statement stmt = null;
        ResultSet rs, rs2 = null;
        try {
            stmt = ConstValue.gConnection.createStatement();
            rs = stmt.executeQuery(sql);
            if (rs.next()) {
                tblInvoiceTamplate tbl = new tblInvoiceTamplate();
                tbl.setInvoiceNo(rs.getString(10));
                tbl.setComapnyName("" + rs.getString(2) + "\n"
                        + rs.getString(3) + ","
                        + rs.getString(4) + ","
                        + rs.getString(5) + ","
                        + rs.getString(6) + ",");
                tbl.setBillTo("" + rs.getString(19) + "\n"
                        + rs.getString(21) + ""
                        + rs.getString(20) + "\n"
                        + rs.getString(22) + ","
                        + rs.getString(23) + ","
                        + rs.getString(24) + ","
                        + rs.getString(25) + ","
                        + rs.getString(26) + ".\nPh No:"
                        + rs.getString(27) + ".\nEmail:"
                        + rs.getString(28));
                    tbl.setShipTo("" + rs.getString(30) + "\n"
                        + rs.getString(32) + ""
                        + rs.getString(31) + "\n"
                        + rs.getString(33) + ","
                        + rs.getString(34) + ","
                        + rs.getString(35) + ","
                        + rs.getString(36) + ","
                        + rs.getString(37) + ","
                        + rs.getString(38));
                tbl.setPoNo(rs.getString(11));
                tbl.setTerms(rs.getString(40));
                tbl.setRep(rs.getString(41));
                tbl.setShipDate(rs.getString(17));
                tbl.setVia(rs.getString(18));
                tbl.setFOB("");
                tbl.setProject("");
                tbl.setTotal(rs.getString(14));
                tbl.setPayment(rs.getString(39));
                tbl.setBalanceDue(rs.getString(15));
                tbl.setDate(rs.getString(16));
                tbl.setPhone(rs.getString(7));
                tbl.setEmail(rs.getString(8));
                List<ProductDetails> details = DetailsFactory.getDetailsList(Long.parseLong(rs.getString(9)));
                tbl.setDetails(details);
 tblInvoiceTamplates.add(tbl);
        }
        } catch (Exception ex) {
            System.out.println(ex);
        }
        return tblInvoiceTamplates;
    }
    }

详细信息与发票工厂相同。它有数据成员,它用于填写子报告。

1 个答案:

答案 0 :(得分:1)

这是因为jasper报告中每个页面上的JRBands 应该重复

理论上你可以设置

<printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>` 

在这些乐队上并避免重复(仅在第一页上印刷)。

但我会建议你使用正确的乐队

如果您希望仅在第一页上设置pageHeader,请将内容移至title频段

对于columnHeadercolumnFooter创建&#34;假组&#34;并使用groupHeadergroupFooter频段

<group name="fakeGroup">
    <groupExpression><![CDATA["fake"]]></groupExpression>
    <groupHeader>
        <band height="50"/>
    </groupHeader>
    <groupFooter>
        <band height="50"/>
    </groupFooter>
</group>