Jump to content
Changes to the Jaspersoft community edition download ×

Multi-line records in reports


Recommended Posts

By: Andy Bergstrom - abergstrom

Multi-line records in reports

2003-04-22 14:04

I would like to have a report that displays two or more lines for each record being displayed. I have specified the XML (see snippet below) to do this but am having problems when an element in the first line expands, the second line does not move down accordingly.

 

It appears somewhat correct when exported to PDF but doesn't look as expected in HTML.

 

In my example I have two lines per record with 3 fields displayed on each line. If the text in the third field on the first line is quite long and wraps several times, then I would expect line 2 of the record to be moved down accordingly. This doesn't appear to happen. Am I missing something here?

 

Also, I would like the column header text to be on multiple lines also. If the static text wraps, how can I properly place the static text on the next line beneath it.

 

I am using Jasper 0.4.5.

 

 

<columnHeader>

<band height="55">

<elementGroup>

<staticText>

<reportElement isPrintWhenDetailOverflows="true" width="151" isRemoveLineWhenBlank="true" forecolor="#FFFFFF" isPrintInFirstWholeBand="true" mode="Opaque" positionType="Float" y="0" x="1" backcolor="#c82838" height="35"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Bold"/>

</textElement>

<text>FIELD #1 ON LINE 1</text>

</staticText>

<staticText>

<reportElement isPrintWhenDetailOverflows="true" width="226" isRemoveLineWhenBlank="true" forecolor="#FFFFFF" isPrintInFirstWholeBand="true" mode="Opaque" positionType="Float" y="0" x="152" backcolor="#c82838" height="35"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Bold"/>

</textElement>

<text>FIELD #2 ON LINE 2</text>

</staticText>

<staticText>

<reportElement isPrintWhenDetailOverflows="true" width="377" isRemoveLineWhenBlank="true" forecolor="#FFFFFF" isPrintInFirstWholeBand="true" mode="Opaque" positionType="Float" y="0" x="378" backcolor="#c82838" height="35"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Bold"/>

</textElement>

<text>FIELD #3 ON LINE 3</text>

</staticText>

</elementGroup>

<staticText>

<reportElement height="1" x="0" forecolor="#c82838" width="752" backcolor="#FFFFFF" mode="Opaque" positionType="Float" y="15"/>

</staticText>

<elementGroup>

<staticText>

<reportElement isPrintWhenDetailOverflows="true" width="249" isRemoveLineWhenBlank="true" forecolor="#FFFFFF" isPrintInFirstWholeBand="true" mode="Opaque" positionType="Float" y="16" x="1" backcolor="#c82838" height="35"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Bold"/>

</textElement>

<text>FIELD #4 ON LINE 2</text>

</staticText>

<staticText>

<reportElement isPrintWhenDetailOverflows="true" width="249" isRemoveLineWhenBlank="true" forecolor="#FFFFFF" isPrintInFirstWholeBand="true" mode="Opaque" positionType="Float" y="16" x="250" backcolor="#c82838" height="35"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Bold"/>

</textElement>

<text>FIELD #5 ON LINE 2</text>

</staticText>

<staticText>

<reportElement isPrintWhenDetailOverflows="true" width="249" isRemoveLineWhenBlank="true" forecolor="#FFFFFF" isPrintInFirstWholeBand="true" mode="Opaque" positionType="Float" y="16" x="499" backcolor="#c82838" height="35"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Bold"/>

</textElement>

<text>FIELD #6 ON LINE 3</text>

</staticText>

</elementGroup>

</band>

</columnHeader>

<detail>

<band height="45">

<staticText>

<reportElement height="1" x="0" width="752" backcolor="#000000" mode="Opaque" positionType="FixRelativeToTop" y="0"/>

</staticText>

<elementGroup>

<textField isBlankWhenNull="true" isStretchWithOverflow="true">

<reportElement height="15" x="1" width="150" mode="Opaque" positionType="Float" y="1"/>

<textElement textAlignment="Left" lineSpacing="Single"/>

<textFieldExpression class="java.lang.Integer">$F{FIELD1}</textFieldExpression>

</textField>

<textField isBlankWhenNull="true" isStretchWithOverflow="true">

<reportElement height="15" x="152" width="225" mode="Opaque" positionType="Float" y="1"/>

<textElement textAlignment="Left" lineSpacing="Single"/>

<textFieldExpression class="java.lang.String">$F{FIELD2}</textFieldExpression>

</textField>

<textField isBlankWhenNull="true" isStretchWithOverflow="true">

<reportElement height="15" x="378" width="376" mode="Opaque" positionType="Float" y="1"/>

<textElement textAlignment="Left" lineSpacing="Single"/>

<textFieldExpression class="java.lang.String">$F{FIELD3}</textFieldExpression>

</textField>

</elementGroup>

<elementGroup>

<textField isBlankWhenNull="true" isStretchWithOverflow="true">

<reportElement height="15" x="1" width="248" mode="Opaque" positionType="Float" y="16"/>

<textElement textAlignment="Left" lineSpacing="Single"/>

<textFieldExpression class="java.lang.String">$F{FIELD4}</textFieldExpression>

</textField>

<textField isBlankWhenNull="true" isStretchWithOverflow="true">

<reportElement height="15" x="250" width="248" mode="Opaque" positionType="Float" y="16"/>

<textElement textAlignment="Left" lineSpacing="Single"/>

<textFieldExpression class="java.lang.String">$F{FIELD5}</textFieldExpression>

</textField>

<textField isBlankWhenNull="true" isStretchWithOverflow="true">

<reportElement height="15" x="499" width="248" mode="Opaque" positionType="Float" y="16"/>

<textElement textAlignment="Left" lineSpacing="Single"/>

<textFieldExpression class="java.lang.String">$F{FIELD6}</textFieldExpression>

</textField>

</elementGroup>

</band>

</detail>

 

 

 

 

 

By: Andy Bergstrom - abergstrom

Correction to XML snippet

2003-04-22 14:07

My column headings in my previous post are probably confusing. Here is a corrected XML to make it clearer:

 

<columnHeader>

<band height="55">

<elementGroup>

<staticText>

<reportElement isPrintWhenDetailOverflows="true" width="151" isRemoveLineWhenBlank="true" forecolor="#FFFFFF" isPrintInFirstWholeBand="true" mode="Opaque" positionType="Float" y="0" x="1" backcolor="#c82838" height="35"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Bold"/>

</textElement>

<text>FIELD #1 ON LINE 1</text>

</staticText>

<staticText>

<reportElement isPrintWhenDetailOverflows="true" width="226" isRemoveLineWhenBlank="true" forecolor="#FFFFFF" isPrintInFirstWholeBand="true" mode="Opaque" positionType="Float" y="0" x="152" backcolor="#c82838" height="35"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Bold"/>

</textElement>

<text>FIELD #2 ON LINE 1</text>

</staticText>

<staticText>

<reportElement isPrintWhenDetailOverflows="true" width="377" isRemoveLineWhenBlank="true" forecolor="#FFFFFF" isPrintInFirstWholeBand="true" mode="Opaque" positionType="Float" y="0" x="378" backcolor="#c82838" height="35"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Bold"/>

</textElement>

<text>FIELD #3 ON LINE 1</text>

</staticText>

</elementGroup>

<staticText>

<reportElement height="1" x="0" forecolor="#c82838" width="752" backcolor="#FFFFFF" mode="Opaque" positionType="Float" y="15"/>

</staticText>

<elementGroup>

<staticText>

<reportElement isPrintWhenDetailOverflows="true" width="249" isRemoveLineWhenBlank="true" forecolor="#FFFFFF" isPrintInFirstWholeBand="true" mode="Opaque" positionType="Float" y="16" x="1" backcolor="#c82838" height="35"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Bold"/>

</textElement>

<text>FIELD #4 ON LINE 2</text>

</staticText>

<staticText>

<reportElement isPrintWhenDetailOverflows="true" width="249" isRemoveLineWhenBlank="true" forecolor="#FFFFFF" isPrintInFirstWholeBand="true" mode="Opaque" positionType="Float" y="16" x="250" backcolor="#c82838" height="35"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Bold"/>

</textElement>

<text>FIELD #5 ON LINE 2</text>

</staticText>

<staticText>

<reportElement isPrintWhenDetailOverflows="true" width="249" isRemoveLineWhenBlank="true" forecolor="#FFFFFF" isPrintInFirstWholeBand="true" mode="Opaque" positionType="Float" y="16" x="499" backcolor="#c82838" height="35"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Bold"/>

</textElement>

<text>FIELD #6 ON LINE 2</text>

</staticText>

</elementGroup>

</band>

</columnHeader>

<detail>

<band height="45">

<staticText>

<reportElement height="1" x="0" width="752" backcolor="#000000" mode="Opaque" positionType="FixRelativeToTop" y="0"/>

</staticText>

<elementGroup>

<textField isBlankWhenNull="true" isStretchWithOverflow="true">

<reportElement height="15" x="1" width="150" mode="Opaque" positionType="Float" y="1"/>

<textElement textAlignment="Left" lineSpacing="Single"/>

<textFieldExpression class="java.lang.Integer">$F{FIELD1}</textFieldExpression>

</textField>

<textField isBlankWhenNull="true" isStretchWithOverflow="true">

<reportElement height="15" x="152" width="225" mode="Opaque" positionType="Float" y="1"/>

<textElement textAlignment="Left" lineSpacing="Single"/>

<textFieldExpression class="java.lang.String">$F{FIELD2}</textFieldExpression>

</textField>

<textField isBlankWhenNull="true" isStretchWithOverflow="true">

<reportElement height="15" x="378" width="376" mode="Opaque" positionType="Float" y="1"/>

<textElement textAlignment="Left" lineSpacing="Single"/>

<textFieldExpression class="java.lang.String">$F{FIELD3}</textFieldExpression>

</textField>

</elementGroup>

<elementGroup>

<textField isBlankWhenNull="true" isStretchWithOverflow="true">

<reportElement height="15" x="1" width="248" mode="Opaque" positionType="Float" y="16"/>

<textElement textAlignment="Left" lineSpacing="Single"/>

<textFieldExpression class="java.lang.String">$F{FIELD4}</textFieldExpression>

</textField>

<textField isBlankWhenNull="true" isStretchWithOverflow="true">

<reportElement height="15" x="250" width="248" mode="Opaque" positionType="Float" y="16"/>

<textElement textAlignment="Left" lineSpacing="Single"/>

<textFieldExpression class="java.lang.String">$F{FIELD5}</textFieldExpression>

</textField>

<textField isBlankWhenNull="true" isStretchWithOverflow="true">

<reportElement height="15" x="499" width="248" mode="Opaque" positionType="Float" y="16"/>

<textElement textAlignment="Left" lineSpacing="Single"/>

<textFieldExpression class="java.lang.String">$F{FIELD6}</textFieldExpression>

</textField>

</elementGroup>

</band>

</detail>

 

 

 

 

 

By: Teodor Danciu - teodord

RE: Multi-line records in reports

2003-05-11 13:53

 

Hi,

 

In case of overflows, elements move downwards

according to positionType="Float" setting only

if there are other elements to push them.

In your case, if there is only one element on the

first line to stretch then it will only push the

element immediately below it, if this one has

positionType="Float".

 

If you want the element on the second line to move

always together, putting them in an

<elementGroup> is not the solution.

Element groups are not for this.

 

A solution would be to put an invisible line

(white on white) between the two rows of text

elements.

Being as wide as the page/column, this horizontal

line will always get pushed downwards, no matter

what is the element above that stretches. And in

turn it will push the elements below.

 

Another solution is two split this band with two

rows that you have in two separate bands using

the dummy groups trick.

 

I hope this helps.

Teodor

 

 

 

 

 

By: Enrico Goosen - enricogoosen

RE: Multi-line records in reports -NEW CAVEAT

2003-05-15 05:58

Hi Teodor,

 

Your solution has fixed my problem partially.

By adding the invisible line, I'm getting all the elements in the second row to line up if one/more elements in the first row stretches. Cool!

The problem:

My textField has a backcolor, to give the illusion of a rectangle. So the textFields that are not stretching are not filling the rectangle backcolor.

Now what?

 

Enrico

 

 

 

 

By: Teodor Danciu - teodord

RE: Multi-line records in reports -NEW CAVEAT

2003-05-17 04:57

 

Hi,

 

To fix this, you have to put behind your text elements

some rectangles, to make it for the text background.

This is beacause as opposed to text elements,

the graphic elements like the rectangles can stretch.

Use the stretchType="RelativeToBandHeight" and

isPrintWhenDetailOverflows="true" for the rectangles.

 

The only problems that could persist is that these

rectangles will not appear in HTML or XLS format,

due to overlapping.

 

I hope this helps.

Teodor

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...