jasper报告中的分页符

时间:2015-12-10 09:59:04

标签: jasper-reports

我在primefaces中使用jasper报告3.7.6。我按照班级按升序排列了从1级到5级的学生列表,并且要打印该列表。如果学生,我的jasper print必须从新页面开始来自不同的班级。如何在碧玉报告中解决这个问题?我的碧玉代码是:

    <?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="AttendenceSheet" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="ireport.zoom" value="2.257895720215118"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <parameter name="ExamDate" class="java.lang.String"/>

    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="rollNo" class="java.lang.String">
        <fieldDescription><![CDATA[rollNo]]></fieldDescription>
    </field>
    <field name="name" class="java.lang.String">
        <fieldDescription><![CDATA[name]]></fieldDescription>
    </field>
    <field name="examDateNp" class="java.lang.String">
        <fieldDescription><![CDATA[examDateNp]]></fieldDescription>
    </field>
    <field name="sn" class="java.lang.Integer">
        <fieldDescription><![CDATA[sn]]></fieldDescription>
    </field>
    <field name="class" class="java.lang.String">
        <fieldDescription><![CDATA[room]]></fieldDescription>
    </field>
    <variable name="sn_1" class="java.lang.Integer" resetType="Page" calculation="Count">
        <variableExpression><![CDATA[$F{sn}]]></variableExpression>
    </variable>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="67" splitType="Stretch">
            <staticText>
                <reportElement x="73" y="21" width="146" height="20"/>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Student Seat Plan Report]]></text>
            </staticText>
            <staticText>
                <reportElement x="411" y="53" width="68" height="13"/>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Exam Date :]]></text>
            </staticText>
            <textField>
                <reportElement x="480" y="53" width="70" height="13"/>
                <textElement verticalAlignment="Middle">
                    <font isBold="false"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$P{ExamDate}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="4" y="53" width="52" height="13"/>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font size="10" isBold="true"/>
                </textElement>
                <text><![CDATA[Class:]]></text>
            </staticText>
            <textField>
                <reportElement x="60" y="53" width="100" height="13"/>
                <textElement/>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{class}]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <columnHeader>
        <band height="23">
            <line>
                <reportElement x="0" y="22" width="556" height="1" isRemoveLineWhenBlank="true"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="0" y="0" width="1" height="23"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="555" y="0" width="1" height="23"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="24" y="0" width="1" height="22"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <staticText>
                <reportElement x="1" y="2" width="22" height="18"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="9" isBold="true"/>
                </textElement>
                <text><![CDATA[SN]]></text>
            </staticText>
            <line>
                <reportElement x="122" y="0" width="1" height="22"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <staticText>
                <reportElement x="27" y="2" width="95" height="18"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="9" isBold="true"/>
                </textElement>
                <text><![CDATA[Roll No.]]></text>
            </staticText>
            <line>
                <reportElement x="272" y="0" width="1" height="22"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <staticText>
                <reportElement x="130" y="0" width="141" height="20"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="9" isBold="true"/>
                </textElement>
                <text><![CDATA[Student Name]]></text>
            </staticText>
            <staticText>
                <reportElement x="281" y="0" width="154" height="21"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="9" isBold="true"/>
                </textElement>
                <text><![CDATA[Signature]]></text>
            </staticText>
            <line>
                <reportElement x="435" y="0" width="1" height="22"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <staticText>
                <reportElement x="436" y="0" width="118" height="21"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="9" isBold="true"/>
                </textElement>
                <text><![CDATA[Remarks]]></text>
            </staticText>
            <line>
                <reportElement x="0" y="0" width="555" height="1"/>
                <graphicElement>
                    <pen lineWidth="0.75"/>
                </graphicElement>
            </line>
        </band>
    </columnHeader>
    <detail>
        <band height="18">
            <line>
                <reportElement x="122" y="0" width="1" height="18"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="272" y="0" width="1" height="18"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <textField>
                <reportElement x="28" y="-1" width="78" height="18"/>
                <textElement verticalAlignment="Middle">
                    <font size="9"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{rollNo}]]></textFieldExpression>
            </textField>
            <line>
                <reportElement x="435" y="0" width="1" height="18"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <textField>
                <reportElement x="3" y="-1" width="19" height="18"/>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font size="9"/>
                </textElement>
                <textFieldExpression class="java.lang.Integer"><![CDATA[$F{sn}]]></textFieldExpression>
            </textField>
            <line>
                <reportElement x="555" y="0" width="1" height="18"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="24" y="0" width="1" height="18"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="0" y="0" width="1" height="18"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <line>
                <reportElement x="0" y="17" width="556" height="1"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </line>
            <textField>
                <reportElement x="127" y="-1" width="145" height="18"/>
                <textElement verticalAlignment="Middle"/>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

1 个答案:

答案 0 :(得分:0)

&#34;正常方式&#34;要实现这一点,请使用属性isStartNewPage="true"的分组,例如$F{class}

示例(在变量定义下插入):

<group name="class" isStartNewPage="true">
    <groupExpression><![CDATA[$F{class}]]></groupExpression>
    <groupHeader>
        <band height="10"/>
    </groupHeader>
    <groupFooter>
        <band height="10"/>
    </groupFooter>
</group>

分组还可以让你使用两个新乐队(如果你的话),groupHeader(通常你把类名放在这个中)和groupFooter(通常你把总和和计数这个乐队中的专栏)