删除嵌套列表中的空行的问题(JasperReports)

时间:2018-02-11 14:11:01

标签: xpath jasper-reports datasource

我想创建一个报告,列出来自xml数据源的订单商品数据。对于每个项目,我想显示项目的名称,类型和ID。订单商品具有树结构,这意味着存在根项目,并且某些根项目可能具有子项目(并且子项目可能具有子项目等)。由于订单商品具有树结构,因此我选择使用报表中的列表和嵌套列表来创建此报表,以便维护树结构。换句话说,如果一个项目可能有一个子项,我已经在[parent]项目列表的边界内为该子项创建了一个嵌套列表。如果根据数据集中的查询找不到给定列表的行,则应删除列表行。我遇到的问题是,当嵌套列表没有行时,有时会显示空格。

以下是示例XML数据:

<xml>
  <order>
    <items>
        <itemId>1</itemId>
        <itemType>G</itemType>
        <name>G1</name>
        <children>
            <childType>typeSV</childType>
            <items>
                <itemId>2</itemId>
                <name>SV1</name>
                <children>
                    <childType>typeCWI</childType>
                </children>
            </items>
        </children>
        <children>
            <childType>typeIAR</childType>
            <items>
                <itemId>3</itemId>
                <name>IAR1</name>
            </items>
        </children>
    </items>
    <items>
        <itemId>4</itemId>
        <itemType>G</itemType>
        <name>G2</name>
        <children>
            <childType>typeSV</childType>
            <items>
                <itemId>5</itemId>
                <name>SV2</name>
                <children>
                    <childType>typeCWI</childType>
                    <items>
                        <itemId>6</itemId>
                        <name>CWI</name>
                        <children>
                            <childType>typeUWSAT</childType>
                            <items>
                                <itemId>7</itemId>
                                <name>UWSAT</name>
                            </items>
                        </children>
                    </items>
                </children>
            </items>
        </children>
    </items>
    <items>
        <itemId>8</itemId>
        <itemType>G</itemType>
        <name>G3</name>
        <children>
            <childType>typeSV</childType>
            <items>
                <itemId>9</itemId>
                <name>SV3</name>
                <children>
                    <childType>typeCWI</childType>
                </children>
            </items>
        </children>
    </items>
    <items>
        <itemId>10</itemId>
        <itemType>G</itemType>
        <name>G4</name>
        <children>
            <childType>typeSV</childType>
        </children>
    </items>
    <items>
        <itemId>11</itemId>
        <itemType>AD</itemType>
        <name>AD1</name>
        <children>
            <childType>typeCP</childType>
            <items>
                <itemId>12</itemId>
                <name>CP1</name>
                <children>
                    <childType>typeAC</childType>
                </children>
            </items>
        </children>
    </items>
</order></xml>

JRXML:

<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="TestXml" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true" uuid="29a85d17-1c73-426a-a943-abd1a79d4d69">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="TextXml"/>
<subDataset name="OrderItems" uuid="afd926ee-2c1e-4872-94e5-c3827d6ee20e">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="TextXml"/>
    <queryString language="xPath">
        <![CDATA[//items]]>
    </queryString>
    <field name="itemId" class="java.lang.String">
        <fieldDescription>
            <![CDATA[itemId]]>
        </fieldDescription>
    </field>
    <field name="name" class="java.lang.String">
        <fieldDescription>
            <![CDATA[name]]>
        </fieldDescription>
    </field>
    <field name="itemType" class="java.lang.String">
        <fieldDescription>
            <![CDATA[itemType]]>
        </fieldDescription>
    </field>
    <field name="childType" class="java.lang.String">
        <fieldDescription>
            <![CDATA[../childType]]>
        </fieldDescription>
    </field>
</subDataset>
<queryString language="xPath">
    <![CDATA[/xml]]>
</queryString>
<background>
    <band splitType="Stretch"/>
</background>
<detail>
    <band height="120" splitType="Stretch">
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
        <frame>
            <reportElement stretchType="ContainerBottom" x="0" y="0" width="560" height="120" isRemoveLineWhenBlank="true" uuid="cd28978a-d108-4dbf-bbdd-e4246bfb3034"/>
            <box>
                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
            </box>
            <componentElement>
                <reportElement positionType="Float" stretchType="ContainerBottom" x="0" y="0" width="560" height="120" isRemoveLineWhenBlank="true" uuid="56683f9b-46b2-432c-bc9d-325c6c4aceed">
                    <property name="net.sf.jasperreports.export.headertoolbar.table.name" value="G"/>
                </reportElement>
                <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
                    <datasetRun subDataset="OrderItems" uuid="5ad748aa-acb5-47eb-96e2-d62692015afc">
                        <dataSourceExpression>
                            <![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/xml/order/items[itemType='G']")]]>
                        </dataSourceExpression>
                    </datasetRun>
                    <jr:listContents height="120" width="560">
                        <frame>
                            <reportElement positionType="Float" stretchType="ContainerBottom" x="0" y="0" width="560" height="30" isRemoveLineWhenBlank="true" uuid="98750caa-ff8c-40da-bddd-57ef7d2db52f"/>
                            <box>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField>
                                <reportElement positionType="Float" stretchType="ContainerBottom" mode="Opaque" x="360" y="0" width="100" height="30" backcolor="#A1A1A1" uuid="d58577b5-f861-496a-877e-c2a288b79d18"/>
                                <box>
                                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textElement textAlignment="Left"/>
                                <textFieldExpression>
                                    <![CDATA[$F{itemType}]]>
                                </textFieldExpression>
                            </textField>
                            <textField>
                                <reportElement positionType="Float" stretchType="ContainerBottom" mode="Opaque" x="460" y="0" width="100" height="30" backcolor="#A1A1A1" uuid="672a536b-199a-4ee3-a363-30e3b255d7f6"/>
                                <box>
                                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <textElement textAlignment="Left"/>
                                <textFieldExpression>
                                    <![CDATA[$F{itemId}]]>
                                </textFieldExpression>
                            </textField>
                            <textField>
                                <reportElement positionType="Float" stretchType="ContainerBottom" mode="Opaque" x="0" y="0" width="359" height="30" backcolor="#A1A1A1" uuid="1670ab91-d0bb-43a1-9898-d8bb9cdaaec8"/>
                                <box>
                                    <leftPen lineWidth="1.0"/>
                                </box>
                                <textElement textAlignment="Left"/>
                                <textFieldExpression>
                                    <![CDATA[$F{name}]]>
                                </textFieldExpression>
                            </textField>
                        </frame>
                        <frame>
                            <reportElement positionType="Float" stretchType="ContainerBottom" x="0" y="30" width="560" height="90" isRemoveLineWhenBlank="true" uuid="b658a693-c1f5-45d8-8cd7-73bc8e77c76e">
                                <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                            </reportElement>
                            <frame>
                                <reportElement positionType="Float" stretchType="ContainerBottom" x="0" y="0" width="560" height="30" isRemoveLineWhenBlank="true" uuid="1f113e02-72f0-4b03-86e1-71a7341837fa"/>
                                <box>
                                    <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                </box>
                                <componentElement>
                                    <reportElement positionType="Float" stretchType="ContainerBottom" x="0" y="0" width="560" height="30" isRemoveLineWhenBlank="true" uuid="67539ab7-8fbe-45ce-9cbf-4f966415a2ef">
                                        <property name="net.sf.jasperreports.export.headertoolbar.table.name" value="IAR"/>
                                    </reportElement>
                                    <jr:list printOrder="Vertical">
                                        <datasetRun subDataset="OrderItems" uuid="1a39b86b-eb8b-4fea-a2f4-d8278390b099">
                                            <dataSourceExpression>
                                                <![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/xml/order/items[itemId='"+$F{itemId}+"']/children[childType='typeIAR']/items")]]>
                                            </dataSourceExpression>
                                        </datasetRun>
                                        <jr:listContents height="30" width="560">
                                            <frame>
                                                <reportElement positionType="Float" x="0" y="0" width="560" height="30" isRemoveLineWhenBlank="true" uuid="bc9e2c9e-bca3-46ba-87aa-5bceb222bda0"/>
                                                <box>
                                                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                </box>
                                                <textField>
                                                    <reportElement positionType="Float" stretchType="ContainerBottom" x="460" y="0" width="100" height="30" uuid="e31e95dc-714f-4f89-85b0-cb2927d3c0a4">
                                                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                                    </reportElement>
                                                    <box>
                                                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                    </box>
                                                    <textFieldExpression>
                                                        <![CDATA[$F{itemId}]]>
                                                    </textFieldExpression>
                                                </textField>
                                                <textField>
                                                    <reportElement positionType="Float" stretchType="ContainerBottom" x="30" y="0" width="330" height="30" uuid="526c14ee-a12e-4156-b130-a7d667136fc2">
                                                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                                    </reportElement>
                                                    <box>
                                                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                    </box>
                                                    <textFieldExpression>
                                                        <![CDATA[$F{name}]]>
                                                    </textFieldExpression>
                                                </textField>
                                                <textField>
                                                    <reportElement positionType="Float" stretchType="ContainerBottom" x="360" y="0" width="100" height="30" uuid="33e53141-5aca-4ec5-af78-edf1c930d7c4">
                                                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                                    </reportElement>
                                                    <box>
                                                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                    </box>
                                                    <textFieldExpression>
                                                        <![CDATA[$F{childType}]]>
                                                    </textFieldExpression>
                                                </textField>
                                            </frame>
                                        </jr:listContents>
                                    </jr:list>
                                </componentElement>
                            </frame>
                            <frame>
                                <reportElement positionType="Float" stretchType="ContainerBottom" x="0" y="30" width="560" height="60" isRemoveLineWhenBlank="true" uuid="38ba008a-05ee-4c35-9d36-c0b3e8fc36ea">
                                    <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                                    <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                </reportElement>
                                <componentElement>
                                    <reportElement positionType="Float" stretchType="ContainerBottom" x="0" y="0" width="560" height="60" isRemoveLineWhenBlank="true" uuid="613fc942-f6b3-449b-836d-58d469bbbc53">
                                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                        <property name="net.sf.jasperreports.export.headertoolbar.table.name" value="SV"/>
                                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                                    </reportElement>
                                    <jr:list printOrder="Vertical">
                                        <datasetRun subDataset="OrderItems" uuid="992b798d-0ad5-4c5b-b245-1a40d055b7f5">
                                            <dataSourceExpression>
                                                <![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/xml/order/items[itemId='"+$F{itemId}+"']/children[childType='typeSV']/items")]]>
                                            </dataSourceExpression>
                                        </datasetRun>
                                        <jr:listContents height="60" width="560">
                                            <frame>
                                                <reportElement positionType="Float" x="0" y="0" width="560" height="30" isRemoveLineWhenBlank="true" uuid="f063936c-ab95-465d-9501-0ed8e5d4dacc"/>
                                                <box>
                                                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                </box>
                                                <textField>
                                                    <reportElement positionType="Float" x="460" y="0" width="100" height="30" uuid="4c7e80d3-6bc4-4281-8c7f-2ba6ba18fa74">
                                                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                                                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                                        <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                                    </reportElement>
                                                    <box>
                                                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                    </box>
                                                    <textFieldExpression>
                                                        <![CDATA[$F{itemId}]]>
                                                    </textFieldExpression>
                                                </textField>
                                                <textField>
                                                    <reportElement positionType="Float" x="30" y="0" width="330" height="30" uuid="96042aa9-402a-4a8f-b008-b3d0ff94becd">
                                                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                                    </reportElement>
                                                    <box>
                                                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                    </box>
                                                    <textFieldExpression>
                                                        <![CDATA[$F{name}]]>
                                                    </textFieldExpression>
                                                </textField>
                                                <textField>
                                                    <reportElement positionType="Float" x="360" y="0" width="100" height="30" uuid="2d3b1a7b-4bfb-4c12-bdaa-741af76a52fd">
                                                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                                                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                                        <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                                    </reportElement>
                                                    <box>
                                                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                    </box>
                                                    <textFieldExpression>
                                                        <![CDATA[$F{childType}]]>
                                                    </textFieldExpression>
                                                </textField>
                                            </frame>
                                            <frame>
                                                <reportElement positionType="Float" stretchType="ContainerBottom" x="0" y="30" width="560" height="30" isRemoveLineWhenBlank="true" uuid="77c3cf69-01ec-41c0-86e0-9b81d17c6a75">
                                                    <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                                    <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                                                </reportElement>
                                                <componentElement>
                                                    <reportElement key="" positionType="Float" stretchType="ContainerBottom" x="0" y="0" width="560" height="30" isRemoveLineWhenBlank="true" uuid="4bec04d5-cd1f-4236-8867-aeba9579161a">
                                                        <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                                        <property name="net.sf.jasperreports.export.headertoolbar.table.name" value="CWI"/>
                                                    </reportElement>
                                                    <jr:list printOrder="Vertical">
                                                        <datasetRun subDataset="OrderItems" uuid="7517e1b5-fef5-4466-acdb-c83b082bbc1a">
                                                            <dataSourceExpression>
                                                                <![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/xml/order/items/children/items[itemId='"+$F{itemId}+"']/children[childType='typeCWI']/items")]]>
                                                            </dataSourceExpression>
                                                        </datasetRun>
                                                        <jr:listContents height="30" width="560">
                                                            <frame>
                                                                <reportElement positionType="Float" stretchType="ContainerBottom" x="0" y="0" width="560" height="30" isRemoveLineWhenBlank="true" uuid="9fcf1658-09b4-4d40-983b-7934d6c44e43"/>
                                                                <box>
                                                                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                                </box>
                                                                <textField>
                                                                    <reportElement positionType="Float" x="460" y="0" width="100" height="30" uuid="c51d6125-185c-4733-bcf2-a9828229b091">
                                                                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                                                                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                                                        <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                                                    </reportElement>
                                                                    <box>
                                                                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                                    </box>
                                                                    <textFieldExpression>
                                                                        <![CDATA[$F{itemId}]]>
                                                                    </textFieldExpression>
                                                                </textField>
                                                                <textField>
                                                                    <reportElement positionType="Float" x="60" y="0" width="300" height="30" uuid="5f06b7e6-7d49-4dee-832f-a5a35285a5a6">
                                                                        <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                                                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                                                    </reportElement>
                                                                    <box>
                                                                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                                    </box>
                                                                    <textFieldExpression>
                                                                        <![CDATA[$F{name}]]>
                                                                    </textFieldExpression>
                                                                </textField>
                                                                <textField>
                                                                    <reportElement positionType="Float" x="360" y="0" width="100" height="30" uuid="259ab20e-a5e5-4fa1-ad8a-4cc602e57ad0">
                                                                        <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                                                                        <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                                                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                                                                    </reportElement>
                                                                    <box>
                                                                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                                                                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                                                    </box>
                                                                    <textFieldExpression>
                                                                        <![CDATA[$F{childType}]]>
                                                                    </textFieldExpression>
                                                                </textField>
                                                            </frame>
                                                        </jr:listContents>
                                                    </jr:list>
                                                </componentElement>
                                            </frame>
                                        </jr:listContents>
                                    </jr:list>
                                </componentElement>
                            </frame>
                        </frame>
                    </jr:listContents>
                </jr:list>
            </componentElement>
        </frame>
    </band>
</detail>

下面我已将此报告导出为.xls格式并截取屏幕截图,以说明我现在遇到的实际结果和所需的结果。

XLS格式的实际结果的屏幕截图(不需要的空格周围有红线): Actual result (with red lines surrounding the unwanted white space)

XLS格式中所需结果的屏幕截图: enter image description here

当IAR项目的嵌套列表没有行时(使用&#34;空行时删除行&#34;选项&#34;)或者没有IAR时,似乎删除了空行。 - 它们各自的嵌套列表也不是SV类型的行。但是,当SV类型项的列表非空且CWI类型项为空时,空白区域显示CWI类型行的位置。我试图通过浮动所有报告组件(例如文本字段,列表,框架等)来删除不需要的空白区域,将所有报告组件的拉伸类型设置为&#34; ElementGroupBottom&#34;和&#34; ContainerBottom&#34;,但无济于事。

有谁知道如何制作此报告以达到预期效果?

1 个答案:

答案 0 :(得分:1)

您可以做的是将List SV元素的高度降低到30,同时将其单元格高度保持为60.这样,当List CWI中没有数据时,单元格高度将保持为30,但是将延伸到60或List CWI生成行时更多。

缺点是在Jaspersoft Sudio的设计视图中,List CWI会被遮挡,你只能通过向下钻取到List SV来看到它。

更改如下:

  • 将列表SV单元格高度保留为60
  • 将SV元素高度从60更改为30(请注意,在此步骤中,Studio可能会自动将单元格高度更改为30,如果这样做,则将其设置为60)
  • 将放置列表SV的帧的高度从60改为30
  • 将父框架的高度从90更改为60
  • 将列表G的元素和单元格高度从120更改为90
  • 将细节带和顶层框架的高度从120更改为90