2011-12-02 172 views
4

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

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

+0

你是什么意思'数据之间的空行? –

+0

假设数据库中有2列包含一些记录,当我在IReports中为数据库和相应记录中的列创建报表并导入它时,M在每个字段之间获得额外的空白行和额外的空白列。 –

回答

7
  • 添加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"/> 

的信息有关的配置属性是here

  • 您可以设置isRemoveLineWhenBlankisBlankWhenNull文本字段元素隐藏空白行。

样品如何如果当前文本字段是空删除整个行:

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

如果这样的设计:

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

你会有任何两行之间的空间。

在此情况下,设计(的TextField高度等于乐队高度): the textfield height is equal to the band's height

的每一行会完全下的其他。

+0

@ user1032041只更新我的答案 –

+0

http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/config.reference.html#net.sf.jasperreports.export.xls.remove.empty.space.between.columns –

+0

Den哪个链接? –

3

Alex K在他12月2日的回答中说的每件事都是正确的。但其他一些设置可能会有所帮助。当报告文本延伸细节带时,这些设置会有所帮助。

论详细带组的每个字段:

positionType = “浮动”

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