1
votes

I have a small detail JasperReports's report developed with iReport. I have the classic Header band and well a row with the values, but below I need to put another textField which is in fact very long up to 500 characters namely Observations. In the Detail row one field can have up to 100 characters (namely CONCEPT) which can cause textField stretch vertically this is working OK. The problem appears when the Concept textField grows vertically the Observations which is below the Detail row stays in the same positions cause both to overlap each other...

Here is some picture of the results so far.

My report has following design (view in iReport):

enter image description here

And the generated report look like this:

enter image description here

As you can see the Observations textField if overlapping the wrap line of the CONCEPTO textField.

UPDATE after following the tips from Alex K i am receving this output....

enter image description here

Here is the code of Detail band:

<detail>
<band height="36" splitType="Stretch">
    <textField pattern="" isBlankWhenNull="true">
       <reportElement x="349" y="0" width="61" height="19"/>
    <textElement textAlignment="Center"/>
    <textFieldExpression class="java.lang.String"><![CDATA[$F{c04}+"€"]]></textFieldExpression>
        </textField>
    <textField pattern="" isBlankWhenNull="true">
        <reportElement x="410" y="0" width="53" height="19"/>
        <textElement textAlignment="Center"/>
        <textFieldExpression class="java.lang.String"><![CDATA[$F{c05}+"€"]]></textFieldExpression>
        </textField>
    <textField isBlankWhenNull="true">
        <reportElement x="240" y="-1" width="57" height="20"/>
        <textElement textAlignment="Right"/>
        <textFieldExpression class="java.lang.String"><![CDATA[$F{c06}]]></textFieldExpression>
        </textField>
    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
        <reportElement x="68" y="0" width="172" height="19"/>
        <textElement/>
        <textFieldExpression class="java.lang.String"><![CDATA[$F{c03}]]></textFieldExpression>
        </textField>
        <textField pattern="" isBlankWhenNull="true">
            <reportElement x="297" y="0" width="51" height="19"/>
            <textElement textAlignment="Center"/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{c02}]]></textFieldExpression>
        </textField>
        <textField isBlankWhenNull="true">
            <reportElement isPrintRepeatedValues="false" x="0" y="0" width="67" height="19"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{c07}]]></textFieldExpression>
        </textField>
        <textField pattern="" isBlankWhenNull="true">
            <reportElement positionType="Float" x="1" y="18" width="554" height="18"/>
            <textElement textAlignment="Left"/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{c08}]]></textFieldExpression>
        </textField>
    </band>
</detail>
1

1 Answers

1
votes

You should set isStretchWithOverflow property as true for textField with long text (contains $F{c03} field in your case) and this properties for textField in the second row (contains $F{c08} field in your sample):

  • positionType with Float value;
  • stretchType with No stretch value;
  • isStretchWithOverflow with true value for support long text.

The sample

The jrxml file:

<?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="overlapping_test" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="c07" class="java.lang.String"/>
    <field name="c03" class="java.lang.String"/>
    <field name="c02" class="java.lang.String"/>
    <field name="c04" class="java.lang.String"/>
    <field name="c05" class="java.lang.String"/>
    <field name="c08" class="java.lang.String"/>
    <columnHeader>
        <band height="20" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="92" height="20"/>
                <textElement/>
                <text><![CDATA[Code]]></text>
            </staticText>
            <staticText>
                <reportElement x="92" y="0" width="92" height="20"/>
                <textElement/>
                <text><![CDATA[Concept]]></text>
            </staticText>
            <staticText>
                <reportElement x="184" y="0" width="92" height="20"/>
                <textElement/>
                <text><![CDATA[Candidate]]></text>
            </staticText>
            <staticText>
                <reportElement x="276" y="0" width="92" height="20"/>
                <textElement/>
                <text><![CDATA[Price]]></text>
            </staticText>
            <staticText>
                <reportElement x="368" y="0" width="92" height="20"/>
                <textElement/>
                <text><![CDATA[Amount]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="40" splitType="Stretch">
            <textField>
                <reportElement x="0" y="0" width="92" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{c07}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement x="92" y="0" width="92" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{c03}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="184" y="0" width="92" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{c02}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="276" y="0" width="92" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{c04}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="368" y="0" width="92" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{c05}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement positionType="Float" x="0" y="20" width="460" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{c08}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

The report's design in iReport:

enter image description here

And the result (via preview in iReport):

enter image description here