【问题标题】:Title Band auto height标题栏自动高度
【发布时间】:2020-08-19 18:30:40
【问题描述】:

根据参数,一些文本字段不会显示在我的报告的标题带标题中。

但标题栏的高度是固定的。因此,当不显示文本字段时,我的标题带中有空白区域。或者当我将带高变小并显示这些字段时会出现编译错误。

那么如何制作动态的Title Band高度呢?

<parameter name="param" class="java.lang.Boolean">
    <defaultValueExpression><![CDATA[true]]></defaultValueExpression>
</parameter>
<title>
    <band height="128" splitType="Stretch">
        <property name="com.jaspersoft.studio.unit.height" value="px"/>
        <staticText>
            <reportElement x="30" y="90" width="100" height="30" uuid="4e7618ed-21d8-47d2-99fb-7b88a5b7cfce">
                <printWhenExpression><![CDATA[$P{param}]]></printWhenExpression>
            </reportElement>
            <text><![CDATA[Static Text]]></text>
        </staticText>
        <textField>
            <reportElement x="30" y="10" width="100" height="30" uuid="005a53c9-a02d-436f-b35d-526ccf4aace9"/>
            <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="30" y="50" width="100" height="30" uuid="caa2031a-3b71-43a2-bb39-916599872e94"/>
            <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
        </textField>
    </band>
</title>
<pageHeader>
    <band height="43" splitType="Stretch">
        <textField>
            <reportElement x="30" y="6" width="100" height="30" uuid="30652d38-43f3-4574-a743-bb6240c2cb52"/>
            <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
        </textField>
    </band>
</pageHeader>

在此示例中,param == false 时有空格。 但是如果我将标题栏高度变小,则会出现编译错误。

【问题讨论】:

  • 你应该发布小的 jrxml 来重现问题
  • 我已经发布了示例。

标签: jasper-reports


【解决方案1】:

对于文本字段,您必须将 isRemoveLineWhenBlank 设置为 true

<reportElement x="30" y="90" width="100" height="30" isRemoveLineWhenBlank="true" uuid="4e7618ed-21d8-47d2-99fb-7b88a5b7cfce">

【讨论】:

    猜你喜欢
    • 2012-06-07
    • 2015-01-16
    • 2023-03-29
    • 2012-09-25
    • 1970-01-01
    • 2011-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多