iReport(JasperReports)额外的行问题
当我从数据库导入数据并在Excel工作表中格式化报表时,数据之间会出现额外的空行。
编辑 (从评论中澄清):在Excel中的输出显示logging之间的额外空白行和字段之间的额外空白列。
- 将
net.sf.jasperreports.export.xls.remove.empty.space.between.columns
和net.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"/>
有关configuration属性的信息在这里 。
- 您可以为textField元素设置isRemoveLineWhenBlank和isBlankWhenNull来隐藏空白行。
如果当前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 )元素的高度。
如果这种devise:
你将有任何两行之间的空间。
如果这个devise( textField高度等于乐队的高度):
每条线都将在另一条线之下。
亚历克斯·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>
这将迫使所有的领域是一个高度。 浮动设置告诉字段,以减less前一行和下一行之间的距离。 RelativeToTallestObject设置指示乐队中的所有字段与最高字段的高度相同。 这两个设置有助于消除在Excel中显示为不需要的单元格的“空白空间”。