繁体   English   中英

iReport (JasperReports) 额外行问题

[英]iReport (JasperReports) extra row issue

当我从数据库导入数据并在 Excel 工作表中格式化报告时,我在数据之间得到一个额外的空行。

编辑(来自评论的澄清):Excel 中的输出显示记录之间的额外空白行和字段之间的额外空白列。

  • net.sf.jasperreports.export.xls.remove.empty.space.between.columnsnet.sf.jasperreports.export.xls.remove.empty.space.between.rows属性添加到报告模板。

net.sf.jasperreports.export.xls.remove.empty.space.between.columns -指定是否应删除空的间隔列。

net.sf.jasperreports.export.xls.remove.empty.space.between.rows -指定是否应删除空的间隔行。

样品:

<jasperReport ...>
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="net.sf.jasperreports.export.xls.remove.empty.space.between.columns" value="true"/>
    <property name="net.sf.jasperreports.export.xls.remove.empty.space.between.rows" value="true"/>

有关配置属性的信息在这里

  • 您可以为textField元素设置isRemoveLineWhenBlankisBlankWhenNull以隐藏空白行。

如果当前textField为空,如何删除整行的示例:

<textField isBlankWhenNull="true">
    <reportElement x="0" y="0" width="100" height="20" isRemoveLineWhenBlank="true"/>
    <textElement/>
    <textFieldExpression><![CDATA[$F{field}]]></textFieldExpression>
</textField>
  • 另一个假设是更改Band中所有textField (或/和staticText )元素的高度。

如果这种设计:

在 textField 和乐队的边界之间有一个空间的设计

您将在任何两行之间有一个空格。

如果这种设计( textField高度等于Band 的高度):文本字段高度等于乐队的高度

每条线将完全在另一条线下方。

Alex K 在 11 年 12 月 2 日的回答中陈述的每件事都是正确的。 但其他一些设置可能会有所帮助。 当报表文本扩展详细信息范围时,这些设置会有所帮助。

在详细信息带集中的每个字段上:

位置类型=“浮动”

拉伸类型="RelativeToTallestObject"

例子:

<detail>
    <band height="20" splitType="Prevent">
        <textField isStretchWithOverflow="true" isBlankWhenNull="true">
            <reportElement positionType="Float" stretchType="RelativeToTallestObject" mode="Transparent" x="372" y="0" width="100" height="20"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{your column name}]]></textFieldExpression>
        </textField>

这将强制所有字段为一个高度。 浮动设置告诉字段最小化前一行和下一行之间的距离。 RelativeToTallestObject 设置告诉带区中的所有字段与最高字段的高度相同。 这两个设置有助于消除在 Excel 中显示为不需要的单元格的“空白空间”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM