java 如何在 JasperReports 中删除行之间的额外空间?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3657517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove extra space between rows in JasperReports?
提问by guest
It is my jrxml code:
这是我的 jrxml 代码:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="example_report" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<field name="name" class="java.lang.String"/>
<field name="test" class="java.lang.String"/>
<field name="price" class="java.lang.Double"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="209" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="209" y="0" width="201" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{test}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="410" y="0" width="145" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.Double"><![CDATA[$F{price}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
When I add collection of data to compiled report in my aplication I get extra space between rows. How to remove this extra space?
当我将数据集合添加到我的应用程序中的编译报告时,我会在行之间获得额外的空间。如何删除这个额外的空间?
回答by Jan Wegner
I think that is because you declare 125px for each row:
我认为这是因为您为每一行声明了 125px:
<detail>
<band height="125" splitType="Stretch">
but use only 20px of that:
但只使用其中的 20px:
<reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="209" height="20"/>
Try to make detail band as height as you use (20px):
尝试将细节带设置为您使用的高度(20 像素):
<detail>
<band height="20" splitType="Stretch">
I'm not sure, because I didn't use Jasper for a few months, but try this.
我不确定,因为我有几个月没有使用 Jasper,但试试这个。