jasper-reports - 标题栏自动高度
问题描述
根据参数,某些文本字段未显示在我的报告的标题带标题中。
但标题栏高度是固定的。因此,当不显示文本字段时,我的标题带中有空白区域。或者当我将带高变小并显示这些字段时出现编译错误。
那么如何制作动态的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
. 但是,如果我将标题带高度变小,则会出现编译错误。
解决方案
您必须为文本字段设置isRemoveLineWhenBlank
为。true
<reportElement x="30" y="90" width="100" height="30" isRemoveLineWhenBlank="true" uuid="4e7618ed-21d8-47d2-99fb-7b88a5b7cfce">
推荐阅读
- python - Unable to Load json using python scrapy
- node.js - Calling disconnect issue with out Async
- c++ - TinyGSM c++ CRTP 实现
- pentaho - how can I pass the result in a shell script to a variable in Job
- python - How to assign the same value for next 11 consecutive months based on a condition in python
- azure - Security concerns when uploading data to Azure Blob Storage directly from frontend
- reactjs - React Spring - 动画列表 - 一次列表中的一项
- apache-spark - Is there a way to re-run only the failed jobs added in a Dataproc workflow template?
- javascript - Typescript - how do you deal with common properties between two interface?
- hapijs - Wreck 的重试机制