How to stretch textfield in a JasperReport as per dynamic content?

Posted by Debadatta Viva la Vida on Stack Overflow See other posts from Stack Overflow or by Debadatta Viva la Vida
Published on 2012-02-21T12:10:41Z Indexed on 2012/11/03 5:02 UTC
Read the original article Hit count: 499

Filed under:
|
|

http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="tree-template" pageWidth="595" pageHeight="842" columnWidth="481" leftMargin="57" rightMargin="57" topMargin="72" bottomMargin="72">

want this field to auto stretch as per content

        <textField isStretchWithOverflow="true" isBlankWhenNull="true">
            <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="80" width="463" height="20"/>
            <textElement>
                <font size="10"/>
            </textElement>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{goals}==null ? "Not Defined":$F{goals}]]></textFieldExpression>
        </textField>

want this field to auto stretch as per content

        <staticText>
            <reportElement stretchType="RelativeToTallestObject" x="0" y="100" width="98" height="20"/>
            <textElement>
                <font isBold="true"/>
            </textElement>
            <text><![CDATA[Status Details]]></text>
        </staticText>
        <textField isStretchWithOverflow="true">
            <reportElement stretchType="RelativeToTallestObject" x="2" y="120" width="463" height="20"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{statusDetails}==null ? "Not Defined":$F{statusDetails}]]></textFieldExpression>
        </textField>
        <staticText>
            <reportElement stretchType="RelativeToTallestObject" x="0" y="140" width="98" height="20"/>
            <textElement>
                <font isBold="true"/>
            </textElement>
            <text><![CDATA[Risk Mitigation]]></text>
        </staticText>
        <textField>
            <reportElement stretchType="RelativeToTallestObject" x="18" y="160" width="463" height="20"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{mitigation}==null?"Not Defined":$F{mitigation}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement stretchType="RelativeToTallestObject" x="79" y="40" width="100" height="20"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[new SimpleDateFormat("MMM dd,yyyy").format($F{releaseDate}.getTime())]]></textFieldExpression>
        </textField>
        <line>
            <reportElement x="0" y="180" width="481" height="1"/>
        </line>
    </band>
</detail>
<columnFooter>
    <band height="12" splitType="Stretch"/>
</columnFooter>
<pageFooter>
    <band height="13" splitType="Stretch">
        <frame>
            <reportElement mode="Opaque" x="0" y="0" width="477" height="13" forecolor="#D0B48E" backcolor="#9DB1B8"/>
            <textField pattern="EEEEE dd MMMMM yyyy">
                <reportElement style="Column header" x="2" y="0" width="197" height="13" forecolor="#FFFFFF"/>
                <textElement verticalAlignment="Middle">
                    <font size="10" isBold="false"/>
                </textElement>
                <textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report">
                <reportElement style="Column header" x="450" y="0" width="27" height="13" forecolor="#FFFFFF"/>
                <textElement verticalAlignment="Middle">
                    <font size="10" isBold="false"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement style="Column header" x="370" y="0" width="80" height="13" forecolor="#FFFFFF"/>
                <textElement textAlignment="Right" verticalAlignment="Middle">
                    <font size="10" isBold="false"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
            </textField>
        </frame>
    </band>
</pageFooter>
<summary>
    <band splitType="Stretch"/>
</summary>

© Stack Overflow or respective owner

Related posts about java

Related posts about jasper-reports