iReport(JasperReports)额外行问题

发布于 2024-12-18 22:34:47 字数 128 浏览 3 评论 0原文

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

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

I am getting an extra empty row between data when I am importing it from the database and formatting the report in Excel sheet.

EDIT (clarification from a comment): The output in Excel shows an extra blank row between records and and extra blank column between fields.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心意如水 2024-12-25 22:34:47
  • 添加 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>
  • 另一个假设是更改所有 textField 的高度(或/和 staticText >) Band 中的元素。

如果是这样的设计:

design with a space Between textField and the band's border

任意两行之间都会有一个空格。

如果是这种设计(textField 高度等于Band's 高度):
the textfield height is equal to the height

每行将恰好位于另一行下方。

  • Add net.sf.jasperreports.export.xls.remove.empty.space.between.columns and net.sf.jasperreports.export.xls.remove.empty.space.between.rows properties to report template.

net.sf.jasperreports.export.xls.remove.empty.space.between.columns - Specifies whether the empty spacer columns should be removed or not.

net.sf.jasperreports.export.xls.remove.empty.space.between.rows - Specifies whether the empty spacer rows should be removed or not.

The sample:

<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"/>

The information about configuration properties is here.

  • You can set isRemoveLineWhenBlank and isBlankWhenNull for textField element for hiding blank row.

The sample how to remove the whole line if the current textField is empty:

<textField isBlankWhenNull="true">
    <reportElement x="0" y="0" width="100" height="20" isRemoveLineWhenBlank="true"/>
    <textElement/>
    <textFieldExpression><![CDATA[$F{field}]]></textFieldExpression>
</textField>
  • Another assumption is to change the height of all textField (or/and staticText) elements in the Band.

In case this design:

design with a space between textField and the band's boundary

you will have a space between any two rows.

In case this design (textField height is equal to the Band's height):
the textfield height is equal to the band's height

the each line will be exactly under the other.

猫卆 2024-12-25 22:34:47

Alex K 在 2011 年 12 月 2 日的回答中所说的一切都是正确的。但其他一些设置可能会有所帮助。当报表文本拉伸详细信息区域时,这些设置会有所帮助。

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

positionType=“Float”

stretchType=“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 中显示为不需要的单元格的“空白区域”。

Every thing that Alex K states in his Dec 2 '11 answer is correct. But a few other settings may be helpful. These settings help when the text of the report stretches the detail band.

On every field in the detail band set:

positionType="Float"

stretchType="RelativeToTallestObject"

Example:

<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>

This will force the all fields to be one height. The float setting tells the field to minimize the distance between the previous and next row. The RelativeToTallestObject setting tells all fields in the band to be the same height as the tallest field. These two settings help eliminate 'empty space' which shows up as unwanted cells in Excel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文