Jasper reports 如何将jasper报告中显示的行数限制为5行?

Jasper reports 如何将jasper报告中显示的行数限制为5行?,jasper-reports,Jasper Reports,我必须更改jasper报告模板 字段1和2是jasper报告数据表的行。Grandtotal显示总数。这里,只需显示传递结果的前5行,但grandtotal必须是提供的所有行的总和。目前。所有查询结果都传递到报表中。因此,它显示所有行。如何更改此模板以仅显示前5行,并取消其余行。但是,grandtotal应该包含所有行的总和。模板如下所示,以供参考。该模板不使用“组”,而仅使用“详图”标注栏 <?xml version="1.0" encoding="UTF-8"?> <ja

我必须更改jasper报告模板

字段1和2是jasper报告数据表的行。Grandtotal显示总数。这里,只需显示传递结果的前5行,但grandtotal必须是提供的所有行的总和。目前。所有查询结果都传递到报表中。因此,它显示所有行。如何更改此模板以仅显示前5行,并取消其余行。但是,grandtotal应该包含所有行的总和。模板如下所示,以供参考。该模板不使用“组”,而仅使用“详图”标注栏

<?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="vehicle_most_frequent " language="groovy" pageWidth="540" pageHeight="720" columnWidth="500" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="00746fd2-b3ac-404d-9dd1-101d4ba25774">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <parameter name="columnNameMap" class="java.util.Map"/>
    <parameter name="param" class="java.util.Map"/>
    <field name="1" class="java.lang.String"/>
    <field name="2" class="java.lang.Long"/>
    <field name="3" class="java.lang.Long"/>
    <variable name="2_sum" class="java.lang.Float" calculation="Sum">
        <variableExpression><![CDATA[$F{2}]]></variableExpression>
    </variable>
    <variable name="2_percent" class="java.lang.Float" calculation="Sum">
        <variableExpression><![CDATA[$F{2}]]></variableExpression>
    </variable>
    <title>
        <band height="39" splitType="Stretch">
            <textField pattern="" isBlankWhenNull="false">
                <reportElement mode="Transparent" x="0" y="0" width="500" height="39" forecolor="#000000" backcolor="#FFFFFF" uuid="08c8dae3-4b33-4877-a71d-cd9669172164"/>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="SansSerif" size="13" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{param}.get("title")]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <columnHeader>
        <band height="28" splitType="Stretch">
            <textField pattern="" isBlankWhenNull="false">
                <reportElement mode="Opaque" x="0" y="0" width="229" height="28" forecolor="#000000" backcolor="#FF8705" uuid="ccbec519-7ab3-4f43-a39c-9542aa5591f6"/>
                <box>
                    <pen lineWidth="1.25" lineStyle="Solid"/>
                    <topPen lineWidth="1.25" lineStyle="Solid"/>
                    <leftPen lineWidth="1.25" lineStyle="Solid"/>
                    <bottomPen lineWidth="1.25" lineStyle="Solid"/>
                    <rightPen lineWidth="1.25" lineStyle="Solid"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{columnNameMap}.get(1)]]></textFieldExpression>
            </textField>
            <textField pattern="" isBlankWhenNull="false">
                <reportElement mode="Opaque" x="229" y="0" width="148" height="28" forecolor="#000000" backcolor="#FF8705" uuid="470b050f-1961-4549-bac3-ccb37880f14d"/>
                <box>
                    <pen lineWidth="1.25"/>
                    <topPen lineWidth="1.25"/>
                    <leftPen lineWidth="1.25"/>
                    <bottomPen lineWidth="1.25"/>
                    <rightPen lineWidth="1.25"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{columnNameMap}.get(2)]]></textFieldExpression>
            </textField>
            <textField pattern="" isBlankWhenNull="false">
                <reportElement mode="Opaque" x="377" y="0" width="123" height="28" forecolor="#000000" backcolor="#FF8705" uuid="bc9d1557-ad50-4301-8c63-8345d5661a08"/>
                <box>
                    <pen lineWidth="1.25"/>
                    <topPen lineWidth="1.25"/>
                    <leftPen lineWidth="1.25"/>
                    <bottomPen lineWidth="1.25"/>
                    <rightPen lineWidth="1.25"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{columnNameMap}.get(3)]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
    <detail>
        <band height="20" splitType="Stretch">
            <textField pattern="" isBlankWhenNull="false">
                <reportElement mode="Transparent" x="0" y="0" width="229" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="d39709a4-ef29-4db6-a5a1-74d1dc5c3bdb"/>
                <box>
                    <pen lineWidth="1.25" lineColor="#000000"/>
                    <topPen lineWidth="1.25" lineColor="#000000"/>
                    <leftPen lineWidth="1.25" lineColor="#000000"/>
                    <bottomPen lineWidth="1.25" lineColor="#000000"/>
                    <rightPen lineWidth="1.25" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{1}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="229" y="0" width="148" height="20" uuid="0af88c77-922f-40f4-8acf-71921f715a14"/>
                <box>
                    <pen lineWidth="1.25"/>
                    <topPen lineWidth="1.25"/>
                    <leftPen lineWidth="1.25"/>
                    <bottomPen lineWidth="1.25"/>
                    <rightPen lineWidth="1.25"/>
                </box>
                <textElement textAlignment="Center"/>
                <textFieldExpression><![CDATA[$F{2}]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Auto" pattern="#,##0.00 %">
                <reportElement x="377" y="0" width="123" height="20" uuid="3692483a-4fe9-44a8-87d7-965ff4f7e2c4"/>
                <box>
                    <pen lineWidth="1.25"/>
                    <topPen lineWidth="1.25"/>
                    <leftPen lineWidth="1.25"/>
                    <bottomPen lineWidth="1.25"/>
                    <rightPen lineWidth="1.25"/>
                </box>
                <textElement textAlignment="Center"/>
                <textFieldExpression><![CDATA[($F{2}?$F{2}/$V{2_sum}:0)]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band height="20" splitType="Stretch">
            <staticText>
                <reportElement mode="Opaque" x="0" y="0" width="229" height="20" forecolor="#000000" backcolor="#FFFF00" uuid="f72b8925-f6cd-4d5e-9617-63e971327211"/>
                <box>
                    <pen lineWidth="1.25"/>
                    <topPen lineWidth="1.25"/>
                    <leftPen lineWidth="1.25"/>
                    <bottomPen lineWidth="1.25"/>
                    <rightPen lineWidth="1.25"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <text><![CDATA[Grandtotal]]></text>
            </staticText>
            <textField evaluationTime="Auto" pattern="" isBlankWhenNull="false">
                <reportElement mode="Opaque" x="229" y="0" width="271" height="20" forecolor="#000000" backcolor="#FFFF00" uuid="a4e37752-e733-4ed5-823f-649eb0a2fa66"/>
                <box>
                    <pen lineWidth="1.25"/>
                    <topPen lineWidth="1.25"/>
                    <leftPen lineWidth="1.25"/>
                    <bottomPen lineWidth="1.25"/>
                    <rightPen lineWidth="1.25"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
                    <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$V{2_sum}]]></textFieldExpression>
            </textField>
        </band>
    </columnFooter>
</jasperReport>


< AlexK >,DUPS并不完美(因为它们是关于页面和大小),我看到你已经回答了一个提到RePrimxMax计数,考虑重新打开并用完整的JRXML示例来回答这个问题。如果我们找不到更好的复制品。@ Alxk,骗子不是完美的(因为它们是关于页面和大小),我看到你已经回答了一个提到RePrimxMax计数,考虑重新打开并用完整的JRXML示例来回答这个问题。(如果我们找不到更好的傻瓜)。