标题栏自动高度
Title Band auto height
根据参数,某些文本字段未显示在我报告的标题栏 header 中。
但是标题栏的高度是固定的。因此,当未显示文本字段时,我的标题栏中有空白 space 。或者当我缩小 band 高度并显示这些字段时出现编译错误。
那么如何制作动态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
为空白 space。
但是,如果我将标题栏的高度设置得更小,则会出现编译错误。
您必须将文本字段的 isRemoveLineWhenBlank
设置为 true
。
<reportElement x="30" y="90" width="100" height="30" isRemoveLineWhenBlank="true" uuid="4e7618ed-21d8-47d2-99fb-7b88a5b7cfce">
根据参数,某些文本字段未显示在我报告的标题栏 header 中。
但是标题栏的高度是固定的。因此,当未显示文本字段时,我的标题栏中有空白 space 。或者当我缩小 band 高度并显示这些字段时出现编译错误。
那么如何制作动态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
为空白 space。
但是,如果我将标题栏的高度设置得更小,则会出现编译错误。
您必须将文本字段的 isRemoveLineWhenBlank
设置为 true
。
<reportElement x="30" y="90" width="100" height="30" isRemoveLineWhenBlank="true" uuid="4e7618ed-21d8-47d2-99fb-7b88a5b7cfce">