碧玉,分页后删除白页

时间:2019-07-24 14:50:12

标签: jasper-reports

我的报告遇到问题,因此我创建了一个简单的示例来查找问题。

SimpleRep.jrxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b  -->
<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="StackOverflowExample" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="749cd048-9a0d-4a00-89bf-1a75a4565943">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <queryString>
        <![CDATA[SELECT  "ORDERS"."SHIPCOUNTRY", 
    Max("ORDERS"."SHIPCOUNTRY") 
FROM  "ORDERS"

GROUP BY "ORDERS"."SHIPCOUNTRY" 
ORDER BY "ORDERS"."SHIPCOUNTRY" ASC]]>
    </queryString>
    <field name="SHIPCOUNTRY" class="java.lang.String">
        <property name="com.jaspersoft.studio.field.label" value="SHIPCOUNTRY"/>
        <property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
    </field>
    <field name="C2" class="java.lang.String">
        <property name="com.jaspersoft.studio.field.label" value="C2"/>
    </field>
    <detail>
        <band height="223">
            <subreport>
                <reportElement x="0" y="50" width="555" height="173" uuid="ed633d08-0959-42bf-a95f-fc66f35b1323"/>
                <subreportParameter name="country">
                    <subreportParameterExpression><![CDATA[$F{SHIPCOUNTRY}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["SimpleSubRep.jasper"]]></subreportExpression>
            </subreport>
            <textField>
                <reportElement x="0" y="0" width="555" height="45" uuid="dc687557-e2f4-4c62-b9ae-bc92dbd62130"/>
                <textElement>
                    <font size="29"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{SHIPCOUNTRY}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

SimpleSubRep.jrxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b  -->
<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="SimpleSubRep" columnCount="2" printOrder="Horizontal" pageWidth="555" pageHeight="802" columnWidth="277" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="ddf05f60-d7c2-4c97-85ea-59b36ddd5382">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <parameter name="country" class="java.lang.String"/>
    <queryString>
        <![CDATA[SELECT   "ORDERS"."ORDERID" 
FROM  "ORDERS"
    WHERE  "ORDERS"."SHIPCOUNTRY" = $P{country}]]>
    </queryString>
    <field name="ORDERID" class="java.lang.Integer">
        <property name="com.jaspersoft.studio.field.label" value="ORDERID"/>
        <property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
    </field>
    <detail>
        <band height="40" splitType="Stretch">
            <textField>
                <reportElement x="0" y="0" width="277" height="40" uuid="a64ae352-8c74-4c2f-95f0-9d2c913244a1">
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textElement>
                    <font size="22"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{ORDERID}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <summary>
        <band height="1">
            <break>
                <reportElement x="0" y="0" width="100" height="1" uuid="8d9d1fb6-1c60-4cdb-acca-9af0b65c3c23"/>
            </break>
        </band>
    </summary>
</jasperReport>

在此示例中,我正在使用JasperStudio 示例数据库
我所拥有的是一份报告,该报告将搜索ORDER表的每个国家/地区,并打印所有订单的ID来自那个国家。

我做了一些屏幕截图:
http://www.zupimages.net/viewer.php?id=19/30/24r2.png

它可以正常工作,但是如果我的主报告有一个摘要带,则报告末尾会出现一个空白页,如果删除摘要带,该空白页就会消失。


这很可能是由子报表末尾的 break元素引起的。
-如果什么也没剩下,最后一个break元素将被删除
-但是我有一个摘要栏,即使摘要栏为空,它也会打印 break元素

任何想法,如果有摘要带,如何删除最后一个空白页?任何技巧或窍门,(虽然我很难使用变量,但似乎找不到解决方法)。

0 个答案:

没有答案