3

这真的让我发疯。我到处阅读,但仍然不明白为什么我的不工作

我有一个主报告(一个只返回一行的虚拟查询)和两个不同的详细信息带中的 2 个子报告(每个都有自己的标题)。第二个子报表拆分为多个 Excel 表!

主报告不包含任何组。它只是一个虚拟查询,没有与子报告的链接。

这是我在主要报告中所做的:

  1. 添加属性:Name="net.sf.jasperreports.export.xls.one.page.per.sheet" 与 Value="True"

  2. 设置忽略分页=“真”

  3. 添加了 Line 元素并设置属性表达式:Name="net.sf.jasperreports.export.xls.break.after.row" 和 Default Value="True"

然后对于第二个子报告:

  1. 设置忽略分页=“真”

我只想要每个子报表的一张 Excel 表。但是第二个子报告被分成多张纸...... :(

有谁知道是什么问题...?

我还在这里阅读了忽略分页和分页符的问题:http: //community.jaspersoft.com/ireport-designer/issues/2575

我正在使用 Jaspersoft iReport Designer 5.0.1

======================================= 我的主要报告的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="Sample_Report28022013" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true" uuid="1808a381-4204-4662-9cc0-7d154bcc0890">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="ireport.jasperserver.reportUnit" value="/reports/Test/Subreports"/>
    <property name="ireport.jasperserver.url" value="http://192.168.17.114:8080/jasperserver/services/repository"/>
    <property name="net.sf.jasperreports.export.xls.one.page.per.sheet" value="True"/>
    <property name="net.sf.jasperreports.export.html.remove.emtpy.space.between.rows" value="True"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["C:\\Documents and Settings\\TreshmaC\\Desktop\\WCHY\\JasperSoft\\"]]></defaultValueExpression>
    </parameter>
    <queryString>
        <![CDATA[SELECT
     tableliste."ident" AS tableliste_ident
FROM
     "public"."tableliste" tableliste
LIMIT 1]]>
    </queryString>
    <field name="tableliste_ident" class="java.lang.Integer"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="7" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="5" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="7" splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="97" splitType="Stretch">
            <subreport>
                <reportElement uuid="ea3a0ff6-f82f-43c0-8c7b-3d06e699f2f0" x="0" y="0" width="555" height="75"/>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["repo:Sample_Report28022013_subreport1.jrxml"]]></subreportExpression>
            </subreport>
            <break>
                <reportElement uuid="3568174b-2ea9-4973-8e12-adcb7f54685a" x="0" y="83" width="100" height="1"/>
            </break>
        </band>
        <band height="94" splitType="Prevent">
            <subreport>
                <reportElement uuid="b6ab1daa-122a-4a4b-8f60-f9fe2ba78204" x="0" y="13" width="555" height="72">
                    <property name="net.sf.jasperreports.export.xls.break.before.row" value="True"/>
                </reportElement>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["repo:Sample_Report28022013_subreport2.jrxml"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
    <columnFooter>
        <band height="7" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="7" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="203" splitType="Stretch">
            <componentElement>
                <reportElement uuid="2651da09-f5ff-45de-91cb-6d9f0a8af724" x="0" y="0" width="555" height="200"/>
                <mp:map xmlns:mp="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                    <mp:latitudeExpression><![CDATA[37.7750f]]></mp:latitudeExpression>
                    <mp:longitudeExpression><![CDATA[-122.4183f]]></mp:longitudeExpression>
                </mp:map>
            </componentElement>
        </band>
    </summary>
</jasperReport>

====================================================第二个子报告的 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="Sample_Report28022013_subreport2" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isIgnorePagination="true" uuid="5a86bc51-7425-4897-b74c-0dcf7016c666">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="ireport.jasperserver.reportUnit" value="/reports/Test/Subreports"/>
    <property name="ireport.jasperserver.url" value="http://192.168.17.114:8080/jasperserver/services/repository"/>
    <property name="net.sf.jasperreports.export.html.remove.emtpy.space.between.rows" value="True"/>
    <queryString>
        <![CDATA[SELECT
     ad_dcr."id_client" AS ad_dcr_id_client,
     ad_dcr."detail_obj_dem" AS ad_dcr_detail_obj_dem,
     ad_dcr."cre_mnt_octr" AS ad_dcr_cre_mnt_octr,
     ad_dcr."cre_mnt_deb" AS ad_dcr_cre_mnt_deb,
     ad_cli."id_client" AS ad_cli_id_client,
     ad_cli."num_port" AS ad_cli_num_port,
     ad_cli."pp_prenom" AS ad_cli_pp_prenom,
     ad_cli."pays" AS ad_cli_pays,
     ad_cli."email" AS ad_cli_email,
     ad_cli."pp_nom" AS ad_cli_pp_nom
FROM
     "public"."ad_cli" ad_cli LEFT JOIN "public"."ad_dcr" ad_dcr ON ad_cli."id_client" = ad_dcr."id_client"
ORDER BY ad_cli."id_client"]]>
    </queryString>
    <field name="ad_dcr_id_client" class="java.lang.Integer"/>
    <field name="ad_dcr_detail_obj_dem" class="java.lang.String"/>
    <field name="ad_dcr_cre_mnt_octr" class="java.math.BigDecimal"/>
    <field name="ad_dcr_cre_mnt_deb" class="java.math.BigDecimal"/>
    <field name="ad_cli_id_client" class="java.lang.Integer"/>
    <field name="ad_cli_num_port" class="java.lang.String"/>
    <field name="ad_cli_pp_prenom" class="java.lang.String"/>
    <field name="ad_cli_pays" class="java.lang.Integer"/>
    <field name="ad_cli_email" class="java.lang.String"/>
    <field name="ad_cli_pp_nom" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="23" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="43" splitType="Stretch">
            <staticText>
                <reportElement uuid="a071e7c5-1a11-497b-9eee-6b243a947965" x="378" y="0" width="177" height="39"/>
                <textElement textAlignment="Right">
                    <font fontName="Castellar" size="26"/>
                </textElement>
                <text><![CDATA[DCR ]]></text>
            </staticText>
        </band>
    </pageHeader>
    <columnHeader>
        <band height="22" splitType="Stretch">
            <frame>
                <reportElement uuid="12e8ca58-2196-4a8a-9137-c5104e63a485" mode="Opaque" x="0" y="0" width="555" height="20" backcolor="#006666"/>
            </frame>
            <staticText>
                <reportElement uuid="a1b68cab-e347-4a8f-87f8-01064a78854f" x="12" y="0" width="100" height="20" forecolor="#FFFFFF"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Client ID]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="8a1870d5-2682-45a1-bf8b-31a613028daf" x="312" y="0" width="143" height="20" forecolor="#FFFFFF"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Achat]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="df37206c-95bf-4d03-8add-3fc7ca1d07a9" x="455" y="0" width="100" height="20" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center">
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Montant]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="40e2dded-de55-4692-8e8d-2e94127dd28e" x="112" y="0" width="100" height="20" forecolor="#FFFFFF"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Nom]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="45abf217-95a0-4ef4-963b-45c2915e5723" x="212" y="0" width="100" height="20" forecolor="#FFFFFF"/>
                <textElement>
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Pays]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="26" splitType="Stretch">
            <textField>
                <reportElement uuid="7f43f0d2-fcc2-45b3-865e-02d643954c1c" x="12" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{ad_dcr_id_client}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement uuid="c14584b6-c516-423a-ac17-bc4ffeb7d74c" x="312" y="0" width="143" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{ad_dcr_detail_obj_dem}]]></textFieldExpression>
            </textField>
            <textField pattern="#,##0.00">
                <reportElement uuid="88cb8587-2e82-4ea6-9c1d-f53767ffb93c" x="455" y="0" width="100" height="20"/>
                <textElement textAlignment="Center"/>
                <textFieldExpression><![CDATA[$F{ad_dcr_cre_mnt_deb}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement uuid="f4feb876-fbb5-4b7b-b9fb-f24528dfb762" x="112" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{ad_cli_pp_nom}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement uuid="5fed5609-a23b-4cbe-a4b2-a0ebf36e3cd5" x="212" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{ad_cli_pays}]]></textFieldExpression>
            </textField>
            <line>
                <reportElement uuid="6eb43b44-1a3f-4b05-be37-4caeb35e5feb" x="0" y="20" width="555" height="1"/>
            </line>
        </band>
    </detail>
    <columnFooter>
        <band height="7" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="8" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="7" splitType="Stretch"/>
    </summary>
</jasperReport>
4

2 回答 2

2

我认为您可以将主报告和子报告中的页面大小设置为某个非常大的值,例如 999999 并在子报告之间从托盘中插入“分页符”。这样,您应该在不同页面中获取每个子报表,但第二个不应跨越多个页面。

于 2013-05-27T11:34:44.897 回答
0

您无需在 Main 中执行任何操作。这一切都在子报告中。比如主要的:

    <detail>
            <band height="397">
                <subreport>
<reportElement positionType="Float" x="0" y="298" width="801" height="99" uuid="61789fb8-f34c-46d4-a13e-6cfeba5567a7">
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    <subreportExpression><![CDATA["repo:"]]></subreportExpression>
                </subreport>
                <subreport>
                    <reportElement positionType="Float" x="0" y="298" width="801" height="99" uuid="61789fb8-f34c-46d4-a13e-6cfeba5567a7">
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    </reportElement>
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    <subreportExpression><![CDATA["repo:"]]></subreportExpression>
                </subreport>
            </band>
        </detail>

并在您拥有的最后一个元素(如文本字段)中使用 BreakAfter:

<textField isBlankWhenNull="true">
                <reportElement x="280" y="0" width="120" height="30" uuid="632a6ed9-70ce-4ecd-a3e0-aaec6af95aa9">
                    <property name="net.sf.jasperreports.export.xls.break.after.row" value="true"/>
                    <property name="net.sf.jasperreports.export.xls.sheet.name" value="Nombre y apellidos"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="11" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["TOTAL"]]></textFieldExpression>
            </textField>

这应该放在报告的末尾

于 2018-01-17T14:25:49.293 回答