R – stretch a row to fit the data in jasper reports using iReport

ireportjasper-reports

How do i stretch a text field to fit the data, If data exceeds the band height the text field doesn't stretch. I have added the text field tag in my jrxml…

The example:

<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
    <reportElement
                    style="dNew"
                    mode="Opaque"
                    x="200"
                    y="0"
                    width="200"
                    height="19"
                    key="value-2"
                    stretchType="RelativeToTallestObject"
                    positionType="Float"
                    isPrintInFirstWholeBand="true"
                    isPrintWhenDetailOverflows="true"/>
    <box></box>
    <textElement textAlignment="Center" verticalAlignment="Top">
        <font fontName="Arial" pdfFontName="Helvetica"/>
    </textElement>
    <textFieldExpression   class="java.lang.String"><![CDATA[$F{DATA2}]]></textFieldExpression>
</textField>

Best Answer

Some bands do not stretch, but if you are talking about the detail band you can do something like this:

<textField isStretchWithOverflow="true" isBlankWhenNull="true">
    <reportElement style="base" positionType="Float" 
       isPrintRepeatedValues="false" x="0" y="3" 
       width="380" height="26" isRemoveLineWhenBlank="true"/>
    <textElement/>
    <textFieldExpression class="java.lang.String">
       <![CDATA[$P{information}]]></textFieldExpression>
</textField>

That is pasted from auto generated XML so there is a lot of extra stuff, but the isStretchWithOverflow="true" should work for you. This will make the field stretch down as the text fills it up.

I ususally use iReport to build my reports and it works quiet nicely. You can switch to an XML view in there too.

Related Topic