Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

jasper reports - Stretch with overflow Detail band not working as expected

I have a simple report. It has two bands title and detail. In the Title I have a static text, in the Detail I have one textField.

The textField is set to stretchwithoverflow = "true". If I set the height for this field to fit one raw information, I get for the larger information one and a half rows. So one textField, in the textField I have 2 rows information, first row displayed correctly, second one - I can see a half height.

Can this be done? Expand only the rows that contain larger information and the larger information will fit well in the text field?

<?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="report7" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="15f9d2dd-21ce-41ec-bcb8-c1aca3a77e37">
    <parameter name="EndDate" class="java.util.Date">
        <defaultValueExpression><![CDATA[new java.util.Date()]]></defaultValueExpression>
    </parameter>
    <parameter name="Project" class="java.util.Collection"/>
    <parameter name="Severity" class="java.util.Collection"/>
    <parameter name="StartDate" class="java.util.Date">
        <defaultValueExpression><![CDATA[new java.util.Date(112, 0, 01)]]></defaultValueExpression>
    </parameter>
    <parameter name="Project_Sets" class="java.util.Collection"/>
    <queryString>
        <![CDATA[some query]]>
    </queryString>
    <field name="crid" class="java.lang.String"/>
    <field name="SEVER" class="java.lang.String"/>
    <field name="product" class="java.lang.String"/>
    <field name="state" class="java.lang.String"/>
    <field name="status" class="java.lang.String"/>
    <field name="submit_date" class="java.lang.String"/>
    <field name="aging" class="java.lang.Long"/>
    <title>
        <band height="25" splitType="Stretch">
            <staticText>
                <reportElement uuid="63eef93a-7e8f-4c69-b9d6-4447fe90673d" x="0" y="0" width="555" height="25" forecolor="#3399FF"/>
                <textElement textAlignment="Center">
                    <font size="16" isBold="true"/>
                </textElement>
                <text><![CDATA[Defects Aging]]></text>
            </staticText>
        </band>
    </title>
    <columnHeader>
        <band height="32">
            <rectangle>
                <reportElement uuid="9a2288d4-87ce-4ee7-b04e-267a7ee0ea8b" x="0" y="0" width="555" height="32" backcolor="#99CC00"/>
            </rectangle>
            <staticText>
                <reportElement uuid="9281aa7a-4bcc-4456-9f25-83c7b2360a01" x="0" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[CRID]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="cacda134-069c-43ae-abc1-76f5c865df41" x="79" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Severity]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="d798786f-5ee0-4e76-8a35-2f908af6e92c" positionType="Float" x="158" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Product]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="6be4792d-01a5-4d18-940d-90f40417c7ad" positionType="Float" x="237" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[State]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="fa447ca9-121c-43fb-a7bf-1b29ada93adf" positionType="Float" x="316" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Status]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="b2d8f1db-871b-4e34-942f-b8c4a87a358b" positionType="Float" x="395" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Submit Date]]></text>
            </staticText>

            <staticText>
                <reportElement uuid="c3eddc7c-25ca-4e29-a01e-13e856b67d03" x="474" y="0" width="79" height="32" forecolor="#FFFFFF"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="Arial" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Days]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="81" splitType="Stretch">
            <elementGroup>
                <textField isStretchWithOverflow="true">
                    <reportElement uuid="6422c6d3-40b9-4e38-8bb4-ded91c91ac17" stretchType="RelativeToBandHeight" x="158" y="0" width="79" height="39"/>
                    <textElement textAlignment="Left" verticalAlignment="Middle"/>
                    <textFieldExpression><![CDATA[$F{product}]]></textFieldExpression>
                </textField>
            </elementGroup>
        </band>
    </detail>
</jasperReport>
See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

In the same band if there are more items and you want to have all same stretched. It has to be set to all of them to stretchType="RelativeToTallestObject" and isStretchWithOverflow="true".

    <textField isStretchWithOverflow="true" pattern="###0">
            <reportElement stretchType="RelativeToTallestObject" x="1576" y="0" width="91" height="20"/>
            <textElement textAlignment="Center"/>
            <textFieldExpression class="java.lang.Long"><![CDATA[$F{count_tohfa}]]></textFieldExpression>
        </textField>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...