繁体   English   中英

碧玉报告中的分页符

[英]page break in jasper report

我在Jasper Reports 3.7.6中使用了Jasper Report 3.7.6,我有一个从1年级到5年级的学生列表,按照班级的升序排列,并希望打印该列表。如果学生来自不同的国家,我的Jasper打印必须从新页面开始类。如何在碧玉报告中解决此问题? 我的碧玉代码是:

    <?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>

实现此目的的“常规方法”是使用属性为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 (通常将总和和列数放在这个带中)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM