Jasper Report动态生成报告错误的内容配置

时间:2017-06-27 07:01:43

标签: jasper-reports

我是Jasper Report的新手,我正在尝试生成动态报告。向用户显示一个对话框,他可以在其中选择要打印的报告的哪些部分。

然后使用一些printWhenExpressions生成报告。问题是当我隐藏一个字段时,下一个字段与第一个字段存在时的位置相同。我想从页面顶部删除此偏移量并自动调整元素以从上到下填充所有页面。另外(我不确定它是否相关)有时我会在报告的最后得到一个空白页。

我已尝试将printWhenExpression应用于整个页面,但它无效。

这是我生成的报告(我正在使用iReport):

<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="Report" pageWidth="650" pageHeight="1000" columnWidth="630" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="10" uuid="fa85ba06-3225-4cc2-b52c-2713413cc58d">
    <detail>
        <band height="596">
            <printWhenExpression><![CDATA[$F{quadroA} || $F{quadroB} || $F{quadroC}]]></printWhenExpression>
            <staticText>
                <reportElement uuid="2069bd6b-05cd-4f29-8172-8007907755ee" style="title" mode="Opaque" x="0" y="0" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroA}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="30" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroA}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="90" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroA}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="150" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroA}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="210" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroA}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <break>
                <reportElement uuid="901e6fb4-1372-4977-9af8-f44d87355e50" positionType="Float" x="0" y="269" width="100" height="1" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroA} && ($F{quadroC} || $F{quadroB} || $F{quadroD} || $F{quadroE} || $F{quadroG} || $F{quadroF} || $F{quadroH} || $F{quadroI})]]></printWhenExpression>
                </reportElement>
            </break>
            <staticText>
                <reportElement uuid="b68bd828-7f67-4e4f-9ac2-be44947cde31" style="title" positionType="Float" x="0" y="270" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroB}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="300" width="630" height="30" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroB}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <staticText>
                <reportElement uuid="c1b5a9f4-19cd-4479-90ac-5146fe38505a" style="title" positionType="Float" x="0" y="372" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroC}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="392" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroC}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="442" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroC}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="491" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroC}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <subreport isUsingCache="true">
                <reportElement uuid="cad17187-7557-4dfd-abd0-49ad5dc0cf52" key="subreport" positionType="Float" x="0" y="330" width="630" height="30" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroB}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="542" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroC}]]></printWhenExpression>
                </reportElement>
            </subreport>
        </band>
        <band height="462">
            <printWhenExpression><![CDATA[$F{quadroD} || $F{quadroE}]]></printWhenExpression>
            <staticText>
                <reportElement uuid="22d99971-9458-4950-9669-093d1395227c" style="title" positionType="Float" x="0" y="78" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroD}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="98" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroD}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="198" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroD}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="248" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroD}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <subreport isUsingCache="true">
                <reportElement uuid="f0c1eb08-9d8b-45bb-9144-6d0ee01b9a88" key="subreport" positionType="Float" x="0" y="148" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroD}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <break>
                <reportElement uuid="f1ceeb7e-7d3f-4c6f-aba7-5ac8ae2dacec" positionType="Float" x="0" y="307" width="100" height="1" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroD} && ($F{quadroE} || $F{quadroG} || $F{quadroF} || $F{quadroH} || $F{quadroI})]]></printWhenExpression>
                </reportElement>
            </break>
            <staticText>
                <reportElement uuid="fa0748f1-27d3-4b61-a032-ddfc378ae533" style="title" positionType="Float" x="0" y="308" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroE}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <subreport isUsingCache="true">
                <reportElement uuid="47d76490-353e-4ec3-a116-a985e720d14b" key="subreport" positionType="Float" x="0" y="338" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroE}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <break>
                <reportElement uuid="edad10a9-33e0-40d9-8824-a7a96d9d5f34" positionType="Float" x="0" y="417" width="100" height="1" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroE} && ($F{quadroG} || $F{quadroF} || $F{quadroH} || $F{quadroI})]]></printWhenExpression>
                </reportElement>
            </break>
            <staticText>
                <reportElement uuid="80666213-c9fe-4744-9591-4006c8d173e7" positionType="Float" x="0" y="388" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{gianos}.isEmpty() && $F{quadroE}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <break>
                <reportElement uuid="992983d0-02df-44cc-b5a7-540bf268ec93" positionType="Float" x="0" y="59" width="100" height="1" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[($F{quadroC} || $F{quadroB}) && ($F{quadroD} || $F{quadroE} || $F{quadroG} || $F{quadroF} || $F{quadroH} || $F{quadroI})]]></printWhenExpression>
                </reportElement>
            </break>
        </band>
        <band height="600">
            <printWhenExpression><![CDATA[$F{quadroF} || $F{quadroG} || $F{quadroH} || $F{quadroI}]]></printWhenExpression>
            <staticText>
                <reportElement uuid="40f68045-80b7-462c-b147-c5a7746eb410" style="title" positionType="Float" x="0" y="144" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroG}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <subreport isUsingCache="true">
                <reportElement uuid="5af4dc78-6286-4989-af44-ab07a58ac73e" key="subreport" positionType="Float" x="0" y="174" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroG}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <break>
                <reportElement uuid="4a8df3d1-3b15-4139-98a4-3fad4ed8f348" positionType="Float" x="0" y="244" width="100" height="1" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[($F{quadroG} || $F{quadroF}) && ($F{quadroH} || $F{quadroI})]]></printWhenExpression>
                </reportElement>
            </break>
            <staticText>
                <reportElement uuid="170bd6d6-81a1-4bed-ab93-840798edbc0b" style="title" positionType="Float" x="0" y="254" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroH}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <subreport isUsingCache="true">
                <reportElement uuid="fc6308d0-d919-4aa3-9a0e-9acfdbe1d793" key="subreport" positionType="Float" x="0" y="284" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroH}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <break>
                <reportElement uuid="9ef198b2-5d32-4a6a-bc23-c87c31af7021" positionType="Float" x="0" y="354" width="100" height="1" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroH} && $F{quadroI}]]></printWhenExpression>
                </reportElement>
            </break>
            <staticText>
                <reportElement uuid="1ccd2dd4-83c2-4e69-a806-8adb7279bf4e" style="title" positionType="Float" x="0" y="364" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroI}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <subreport isUsingCache="true">
                <reportElement uuid="a6f3ace1-27ac-4b55-8005-c7cfbcc2d74c" key="subreport" positionType="Float" x="0" y="394" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroI}]]></printWhenExpression>
                </reportElement>
            </subreport>
            <staticText>
                <reportElement uuid="4fcd31f2-d6f6-49e5-a14f-ffd23070f383" positionType="Float" x="0" y="224" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{smt}.isEmpty() && $F{quadroG}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <staticText>
                <reportElement uuid="b3ae5054-a5a0-4068-a614-3218b9663c70" positionType="Float" x="0" y="334" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{r}.isEmpty() && $F{quadroH}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <staticText>
                <reportElement uuid="77a933cf-c457-45db-9576-053c4c692fd5" positionType="Float" x="0" y="98" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{e}.isEmpty() && $F{quadroF}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <staticText>
                <reportElement uuid="71aa9131-7ff8-4d32-932d-f58876bb3871" positionType="Float" x="0" y="444" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{r}.isEmpty() && $F{quadroI}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <staticText>
                <reportElement uuid="25b337a0-acca-4ffa-96eb-251e8a507246" style="title" positionType="Float" x="0" y="18" width="630" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroF}]]></printWhenExpression>
                </reportElement>
            </staticText>
            <subreport isUsingCache="true">
                <reportElement uuid="77660a36-1c0f-4c56-b04c-13cdd0ca7c80" key="subreport" positionType="Float" x="0" y="48" width="630" height="50" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[$F{quadroF}]]></printWhenExpression>
                </reportElement>
            </subreport>
        </band>
    </detail>
</jasperReport>

有人能告诉我是否有可以设置的属性来实现这种行为?

谢谢!

修改

我已经在重复的问题建议中尝试了解决方案(正如您所看到的,我已经在每个元素上设置了isRemoveLineWhenBlank),但这并没有解决问题。

0 个答案:

没有答案