Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
855 views
in Technique[技术] by (71.8m points)

java - How to remove extra space between rows in JasperReports?

It is my jrxml code:

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think that is because you declare 125px for each row:

<detail>
    <band height="125" splitType="Stretch">

but use only 20px of that:

<reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="209" height="20"/>

Try to make detail band as height as you use (20px):

<detail>
    <band height="20" splitType="Stretch">

I'm not sure, because I didn't use Jasper for a few months, but try this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...