Auto height rectangle in detail band - jasper-reports

I am using iReport. I want to know how to make an auto height rectangle?
as per this sample image of detail band. There is two part one is data part on right side which fetch data and show. and left side part is a textarea data which is passed as parameter.
I want to make both rectangle same height. It may possible that left side data height is bigger than right side part and vice versa. So I want to make both rectangle height same all the time.
For achieving this i use following code. where I don't use rectangles but a lines only
<columnHeader>
<line>
<reportElement x="0" y="28" width="555" height="1" uuid="9d2cb019-77f2-47a0-94f7-aa944b5c277e"/>
</line>
</band>
</columnHeader>
<detail>
<band height="13" splitType="Stretch">
<textField>
<reportElement x="472" y="0" width="50" height="13" uuid="4b51d986-b6f9-45e2-a151-e9d7f86007f3"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{packing}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="526" y="0" width="27" height="13" uuid="930cf91c-710a-40c4-a899-fde5ddfd7ce4"/>
<textElement verticalAlignment="Middle">
<font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{sli_pack}]]></textFieldExpression>
</textField>
<line>
<reportElement x="471" y="0" width="1" height="13" uuid="434d1954-3286-4539-a3d9-915f28364210"/>
</line>
<line>
<reportElement x="555" y="-1" width="1" height="13" uuid="39dab81d-1bb3-41bd-8fff-9780b7f65672"/>
</line>
<line>
<reportElement x="0" y="-1" width="1" height="13" uuid="8936db56-872f-434d-a39b-298ffdb99e57"/>
</line>
</band>
</detail>
<summary>
<band height="1" splitType="Stretch">
<line>
<reportElement x="0" y="-1" width="555" height="1" uuid="ba7dbcc7-fd20-4ee9-b593-480737f9b88c"/>
</line>
</band>
</summary>
But the issue with this way is corners of rectangle is not properly printed.
My questions are:
1) Is there any better way to do this?
2) how to draw a border of complete detail band?
3) How to do this with rectangle ?
Here is another try with rectangle around detail band but rectangle is repeated to each row.
<detail>
<band height="13" splitType="Stretch">
<rectangle>
<reportElement stretchType="RelativeToTallestObject" x="1" y="0" width="552" height="13" uuid="80b946be-ac5f-495d-a507-fec3e22ea751"/>
</rectangle>
<textField>
<reportElement x="465" y="0" width="50" height="13" uuid="4b51d986-b6f9-45e2-a151-e9d7f86007f3"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{packing}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="526" y="0" width="27" height="13" uuid="930cf91c-710a-40c4-a899-fde5ddfd7ce4"/>
<textElement verticalAlignment="Middle">
<font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{sli_pack}]]></textFieldExpression>
</textField>
</band>
</detail>

Hello I think you can find the answer in their documentation in this Link:
https://community.jaspersoft.com/wiki/dynamically-set-table-row-height-data
To sum up here are the options you should enable.

I think you should have one rectangle and place a line in between. Use the property of line, check stretchWithOverflow to true. Simillarly with rectangle.

First select your field and set following properties (third one is most important):
Position type: float
Stretch type: relative to tallest object
Stretch with overflow: true (checked)

Related

Extra blank page after page with list

Here is my JRXML On the second page I created a table using the nested list. In Preview in Jaspersoft Studio everything looks good, but after generating PDF on the page where my nested list is, an empty page is added. I have no idea how I can fix this problem.
I tried:
Remove Line When Blank - for lists and fields.
When No Data Type - all options tried and tested.
I have a problem with generating an additional blank page in PDF. Our company system does not support generating reports from subreports to multiple pages. As a workaround, a 43 page printout was created and each page is divided by "Page Break". This works well. My data source is an XML file.
I've tried to solve previously given here in similar problems but it doesn't help.
I don't want to generate this empty page.
Part of nested list code:
<componentElement>
<reportElement x="0" y="240" width="555" height="40" uuid="5a5114e6-f143-4e73-9a70-6aa3285b4d31">
</reportElement>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="OrderItems" uuid="a5783264-74e9-43b2-8312-84e805170f06">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/wstxns1:XML/wstxns1:p7_Object/wstxns1:productOrder/wstxns1:items")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="40" width="555">
<textField>
<reportElement style="Table_TD" x="0" y="0" width="185" height="20" uuid="9f67e274-92bc-4a21-8403-d60b4115c5c3">
</reportElement>
<textElement>
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{prospect/name}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Table_TD" x="185" y="0" width="185" height="20" uuid="262d8477-4cdc-47dc-b746-b38793e05757">
</reportElement>
<textElement textAlignment="Right">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[($F{totalReccuringChargeAmount}!=null)?(new BigDecimal($F{totalReccuringChargeAmount}).setScale(2, BigDecimal.ROUND_HALF_UP)).toString() + " " + $F{totalReccuringChargecurrency}:""]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Table_TD" x="370" y="0" width="185" height="20" uuid="a9aad9d3-9269-427e-b0e7-032f582c44e7">
</reportElement>
<textElement textAlignment="Right">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{commitmentPeriod[Level0]}]]></textFieldExpression>
</textField>
<componentElement>
<reportElement x="0" y="20" width="555" height="20" isRemoveLineWhenBlank="true" uuid="96c06463-aaa8-4ee9-80be-0110bbc8258c">
</reportElement>
<jr:list printOrder="Vertical">
<datasetRun subDataset="OrderItems" uuid="100d9171-37f5-45fc-b7b8-affe80e508af">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("//wstxns1:items[wstxns1:itemId = '"+$F{itemId}+"']/wstxns1:configuration/wstxns1:prospect/wstxns1:children/wstxns1:items")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="20" width="555">
<textField>
<reportElement style="Table_TD" x="0" y="0" width="185" height="20" uuid="1e3d8870-3a1f-4cd2-923d-ac1547d5805f">
</reportElement>
<textElement>
<font fontName="SansSerif" size="9"/>
</textElement>
<textFieldExpression><![CDATA["--"+$F{prospect/name}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Table_TD" x="185" y="0" width="185" height="20" uuid="8dee85a5-406b-4a81-ab42-1d29ade1ceab">
</reportElement>
<textElement textAlignment="Right">
<font fontName="SansSerif" size="9"/>
</textElement>
<textFieldExpression><![CDATA[($F{totalReccuringChargeAmount}!=null)?(new BigDecimal($F{totalReccuringChargeAmount}).setScale(2, BigDecimal.ROUND_HALF_UP)).toString() + " " + $F{totalReccuringChargecurrency}:""]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Table_TD" x="370" y="0" width="185" height="20" uuid="80044161-2cc9-461d-bb6b-4b7426d9479c">
</reportElement>
<textElement textAlignment="Right">
<font fontName="SansSerif" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{commitmentPeriod[Level1]}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</jr:listContents>
</jr:list>
</componentElement>
<textField>
<reportElement style="Table_TH" positionType="Float" x="185" y="280" width="185" height="30" backcolor="#D9D9D9" uuid="9e550a00-d376-4f3d-859e-9f3ebd875b76">
</reportElement>
<box>
<pen lineWidth="0.5"/>
</box>
<textElement textAlignment="Right" verticalAlignment="Top">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[($F{mainOrderTotalAmount}!=null)?(new BigDecimal($F{mainOrderTotalAmount}).setScale(2, BigDecimal.ROUND_HALF_UP)).toString()+" "+$F{mainOrderCurrency}:" "]]></textFieldExpression>
</textField>
<staticText>
<reportElement style="Table_TH" positionType="Float" x="0" y="280" width="185" height="30" backcolor="#D9D9D9" uuid="aa918c59-db11-49ad-8ab1-1e296b8e8b08">
</reportElement>
<textElement textAlignment="Right">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<text><![CDATA[Total: ]]></text>
</staticText>
<staticText>
<reportElement style="Table_CH" x="0" y="210" width="185" height="30" backcolor="#D9D9D9" uuid="5e3cea42-8937-4876-9ef3-4fef54ae66db">
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<text><![CDATA[Package name]]></text>
</staticText>
<staticText>
<reportElement style="Table_CH" x="185" y="210" width="185" height="30" backcolor="#D9D9D9" uuid="a76bf537-65a0-400f-a75a-b0f03bd88796">
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<text><![CDATA[Monthly charge]]></text>
</staticText>
<staticText>
<reportElement style="Table_CH" x="370" y="210" width="185" height="30" backcolor="#D9D9D9" uuid="6893b476-bcc2-42ab-8078-364f13b6fcf6">
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="9" isBold="true"/>
</textElement>
<text><![CDATA[Contract period]]></text>
</staticText>
<staticText>
<reportElement x="0" y="750" width="555" height="40" uuid="eb235aed-5c5e-4ef3-b9ab-f776e5307aa9">
</reportElement>
<textElement>
<font fontName="SansSerif" size="9"/>
</textElement>
<text><![CDATA[O749504]]></text>
</staticText>
</band>
Any ideas guys? Maybe you need more details?
Maybe this will help you:
Set the split Typ of the detail band to Stretch:
splitType="Stretch"
best wishes
We had a similar problem. If the a list was the last item in the page in same cases a blank page was added.
When we added the whole list to a new band the empty page disappeared.

Why does the detail-band grow on second page?

I'm defining a report for invoices, an invoice may have n items (rows) in the detail. I defined a dataset in order to display the items without the need of a subreport. Here my Detail-band:
<detail>
<band height="275" splitType="Stretch">
<rectangle>
<reportElement x="0" y="0" width="60" height="16" uuid="590f4cac-fba0-4e0b-aa74-db059a817946"/>
</rectangle>
<rectangle>
<reportElement x="60" y="0" width="140" height="16" uuid="1cc31301-e884-4648-952d-a68bcaa12b23"/>
</rectangle>
<rectangle>
<reportElement x="200" y="0" width="31" height="16" uuid="ac690ad3-a913-454f-80d0-574505609db1"/>
</rectangle>
<rectangle>
<reportElement x="231" y="0" width="100" height="16" uuid="6d623fd0-df6f-4ffd-b92b-8f18e0d2d5b2"/>
</rectangle>
<rectangle>
<reportElement x="331" y="0" width="37" height="16" uuid="afef801a-3280-4810-8d85-c1f591d2b75b"/>
</rectangle>
<staticText>
<reportElement x="3" y="2" width="44" height="11" uuid="f525bb2b-106a-44a3-9fb0-817f1eeb8260"/>
<textElement>
<font size="6"/>
</textElement>
<text><![CDATA[Artikel]]></text>
</staticText>
<staticText>
<reportElement x="63" y="2" width="126" height="11" uuid="0f97aa9e-cb83-4a95-92fc-fdc01e1506f1"/>
<textElement>
<font size="6"/>
</textElement>
<text><![CDATA[Beschreibung]]></text>
</staticText>
<staticText>
<reportElement x="207" y="2" width="22" height="11" uuid="6234d14c-abe2-482e-b6bb-f1c65dc19005"/>
<textElement textAlignment="Right">
<font size="6"/>
</textElement>
<text><![CDATA[Menge]]></text>
</staticText>
<staticText>
<reportElement x="237" y="2" width="92" height="11" uuid="2bd9712e-b8be-4b90-823d-a530f6c7dcba"/>
<textElement textAlignment="Right">
<font size="6"/>
</textElement>
<text><![CDATA[Einheitspreis]]></text>
</staticText>
<staticText>
<reportElement x="340" y="2" width="25" height="11" uuid="dbf02042-62f2-4b70-9b8b-fae588cb8055"/>
<textElement textAlignment="Right">
<font size="6"/>
</textElement>
<text><![CDATA[Rabatt]]></text>
</staticText>
<rectangle>
<reportElement x="368" y="0" width="70" height="16" uuid="54f1f443-d742-4287-8ae6-d06b04682bf4"/>
</rectangle>
<rectangle>
<reportElement x="437" y="0" width="34" height="16" uuid="f23aa7d5-3eb9-478a-a799-a8acfe96d7af"/>
</rectangle>
<rectangle>
<reportElement x="471" y="0" width="84" height="16" uuid="7b4a3a55-b161-44c7-8512-33a127d68ba3"/>
</rectangle>
<staticText>
<reportElement x="381" y="2" width="54" height="11" uuid="e12d9869-3dcd-4b81-89f8-b3a3c6b2e28c"/>
<textElement textAlignment="Right">
<font size="6"/>
</textElement>
<text><![CDATA[MwSt. Grundlage]]></text>
</staticText>
<staticText>
<reportElement x="441" y="2" width="28" height="11" uuid="fb7f8a0e-1632-454f-9742-5179831c8dc4"/>
<textElement textAlignment="Right">
<font size="6"/>
</textElement>
<text><![CDATA[MwSt.]]></text>
</staticText>
<staticText>
<reportElement x="505" y="2" width="47" height="11" uuid="da9a079f-dc7e-4fef-9f31-eabd65340967"/>
<textElement textAlignment="Right">
<font size="6"/>
</textElement>
<text><![CDATA[MwSt. Betrag]]></text>
</staticText>
<rectangle>
<reportElement x="0" y="16" width="60" height="248" uuid="cd7f5e9a-aeae-425c-8783-22084707b432"/>
</rectangle>
<rectangle>
<reportElement x="60" y="16" width="140" height="248" uuid="01ee9155-aed8-4a55-8160-5f73ac6b1085"/>
</rectangle>
<rectangle>
<reportElement x="200" y="16" width="31" height="248" uuid="66698906-69ee-4fdc-8a04-ce14372bd065"/>
</rectangle>
<rectangle>
<reportElement x="231" y="16" width="100" height="248" uuid="0c260fbe-b300-4962-ad7b-ff7666fa2baa"/>
</rectangle>
<rectangle>
<reportElement x="331" y="16" width="37" height="248" uuid="1902828b-f84c-440c-8e3f-24cdffea33ec"/>
</rectangle>
<rectangle>
<reportElement x="368" y="16" width="69" height="248" uuid="880c1b82-4316-493a-b5b3-c4342bbb74c9"/>
</rectangle>
<rectangle>
<reportElement x="437" y="16" width="34" height="248" uuid="ee1c4e69-b69e-4cc8-9b83-24e9867012de"/>
</rectangle>
<rectangle>
<reportElement x="471" y="16" width="84" height="248" uuid="eade602d-0afa-4a6e-a3aa-5de350dc2ee5"/>
</rectangle>
<componentElement>
<reportElement x="0" y="16" width="555" height="17" uuid="be7e1e99-0990-4f3d-beaf-b304c08be036"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="items" uuid="ab906203-20bb-4347-806b-ef000f212bf9">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{righeDocumento})]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="17" width="555">
<textField>
<reportElement x="3" y="2" width="56" height="14" uuid="448ef958-9459-4ab1-8896-f5b65dd7a552"/>
<textFieldExpression><![CDATA[$F{articolo}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="63" y="2" width="136" height="14" uuid="24634427-d38f-4679-8996-a96d5051774b"/>
<textFieldExpression><![CDATA[$F{descrizione}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="236" y="2" width="92" height="14" uuid="20bda0b8-a3c0-47e7-bdff-555c481a894d"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[new DecimalFormat("0.00 €").format($F{prezzo})]]></textFieldExpression>
</textField>
<textField>
<reportElement x="207" y="2" width="21" height="14" uuid="61766ba4-57d0-4509-ac41-ffd7bb4e12ef"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{quantita}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="338" y="2" width="27" height="14" uuid="535705c6-d0b6-401d-b767-efafb3ba42f7"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{sconto} == null ? "" : $F{sconto}+" %"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="439" y="2" width="28" height="14" uuid="0dc5fa14-efac-4c5b-898a-9a9152e588f7"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{aliquota}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="375" y="2" width="59" height="14" uuid="2772b49b-5355-463d-bebf-856537a416a3"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[new DecimalFormat("0.00 €").format($F{costo})]]></textFieldExpression>
</textField>
<textField>
<reportElement x="482" y="2" width="70" height="14" uuid="0259a153-a0c2-4589-b296-fdca4ceeed2b"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[new DecimalFormat("0.00 €").format($F{iva})]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</detail>
The result is to see in the following pictures:
Example with many rows:
Example with two rows:
The problem is that when I have more rows it includes a second page (not shown here in my question) with header and footer, the detail is empty. The rest as we can see from the pics is OK.
Why? How do I fix it?
You have chosen a strange way to create this report, the normal way would be to make the detail band represent 1 article line in your invoice (hence detail band would have the height of 14)
Then if you need to draw lines to the bottom of the page you can always use the background band.
What is happening now?, probably the list overflows in your detail band that also have empty space under it, it can not create another one on same page and move the space to next page.
Solution Use the normal way of jasper report, datasource containing your lines, header in columnHeader band, fields in detail band (height 14) and your vertical lines in
the background band, also exports as to excel etc will be much cleaner.
If you like to keep your list, move all the rectangles to the
background band and reduce height of detail band to remaining
components (header + list height)

How to set x, y for a textElement in JasperReports depending on if above textElement is empty. And if non-empty show it down to the that textelement

Requirement:
If firstName and lastName is non empty. Show this at x=125, y=3 coordinates.
And show address down to it at x="125" y="26" coordinate. This is working fine.
Problem: If firstName/lastName are empty, Then we need to move the address element up and show it at x=125, y=3 coordinate itself.
This is where I am stuck. Please help me.
Please refer my jrxml file below:
<frame>
<reportElement key="frame-462" positionType="Float" mode="Transparent" x="0" y="50" width="390" height="70"/>
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now">
<reportElement key="textField-844" positionType="Float" mode="Transparent" x="125" y="3" width="264" height="23"
isPrintWhenDetailOverflows="true" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[(!$F{firstName}.isEmpty() && !$F{lastName}.isEmpty())]]></printWhenExpression>
</reportElement>
<textElement markup="styled">
<font fontName="Verdana" size="12"/>
</textElement>
<textFieldExpression>
<![CDATA[$F{firstName} + "<style pdfFontName='Helvetica-Oblique' size='11'>" + $F{lastName} + "</style>"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now">
<reportElement key="textField-843" mode="Transparent" positionType="Float" x="125" y="26" width="264"
height="42" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true"/>
<textElement markup="html">
<font fontName="Verdana" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
<staticText>
<reportElement key="staticText-1249" positionType="Float" x="2" y="2" width="108" height="21"
isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Left">
<font fontName="Verdana" size="12" isBold="false" pdfFontName="Helvetica-Bold"/>
</textElement>
<text><![CDATA[ Address:]]></text>
</staticText>
</frame>
You have already set the isRemoveLineWhenBlank attribute, which will remove the empty space left by the textField. However, JasperReports cannot collapse vertical space unless that space is completely clear. If there is another element occupying the same line (in your case the staticText element), the empty space will be preserved. This is a bit like playing Tetris in reverse; You have to get rid of all of the blocks before the line will disappear.
Putting report elements into frames modifies this behaviour slightly. It is only the width of the parent frame that needs to be clear, instead of the width of the whole report. Therefore, by putting your name and address fields into a separate frame, the space occupied by the name field can collapse despite being aligned horizontally with the static text. I have modified your code snippet to demonstrate this:
<frame>
<reportElement key="frame-462" positionType="Float" mode="Transparent" x="0" y="50" width="390" height="70"/>
<frame>
<reportElement x="126" y="0" width="264" height="70"/>
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now">
<reportElement key="textField-844" positionType="Float" mode="Transparent" x="0" y="3" width="264" height="23" isPrintWhenDetailOverflows="true" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[(!$F{firstName}.isEmpty() && !$F{lastName}.isEmpty())]]></printWhenExpression>
</reportElement>
<textElement markup="styled">
<font fontName="Verdana" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{firstName} + "<style pdfFontName='Helvetica-Oblique' size='11'>" + $F{lastName} + "</style>"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now">
<reportElement key="textField-843" mode="Transparent" positionType="Float" x="0" y="26" width="264" height="42" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true"/>
<textElement markup="html">
<font fontName="Verdana" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
</frame>
<staticText>
<reportElement key="staticText-1249" positionType="Float" x="2" y="2" width="108" height="21" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Left">
<font fontName="Verdana" size="12" isBold="false" pdfFontName="Helvetica-Bold"/>
</textElement>
<text><![CDATA[ Address:]]></text>
</staticText>
</frame>

JasperReports: Headers Not In The Same Line

The header of the report consists 10 elements it should look like this:
|1 2 3 4 5 6 7 8 9 10|
|--------------------|
In reality it look like this:
|1 2 8 9 10|
|---3 4 5 6 7 ------|
Is this something to do with the verticalAligment? I have set it to Bottom.
The snippet from my jrxml file:
<pageHeader>
<band height="0" isSplitAllowed="true" >
</band>
</pageHeader>
<columnHeader>
<band height="39" isSplitAllowed="true" >
<rectangle>
<reportElement
x="0"
y="1"
width="780"
height="30"
backcolor="#999999"
key="rectangle-1"/>
<graphicElement stretchType="NoStretch"/>
</rectangle>
<staticText>
<reportElement
x="0"
y="0"
width="40"
height="30"
key="staticText-1"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Holder Id]]></text>
</staticText>
<staticText>
<reportElement
x="40"
y="0"
width="50"
height="30"
key="staticText-2"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Shell Id ]]></text>
</staticText>
<staticText>
<reportElement
x="100"
y="1"
width="50"
height="30"
key="staticText-3"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Product Id]]></text>
</staticText>
<staticText>
<reportElement
x="160"
y="1"
width="40"
height="30"
key="staticText-4"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[SPID]]></text>
</staticText>
<staticText>
<reportElement
x="200"
y="1"
width="40"
height="30"
key="staticText-5"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Loc-
ation]]></text>
</staticText>
<staticText>
<reportElement
x="300"
y="1"
width="50"
height="30"
key="staticText-6"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Date]]></text>
</staticText>
<staticText>
<reportElement
x="350"
y="1"
width="30"
height="30"
key="staticText-7"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Normal Fare]]></text>
</staticText>
<staticText>
<reportElement
x="380"
y="1"
width="30"
height="30"
key="staticText-8"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Actual Fare]]></text>
</staticText>
<staticText>
<reportElement
x="410"
y="1"
width="40"
height="30"
key="staticText-9"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Currency Code]]></text>
</staticText>
<staticText>
<reportElement
x="450"
y="1"
width="30"
height="30"
key="staticText-10"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Staff Id]]></text>
</staticText>
<staticText>
<reportElement
x="250"
y="1"
width="40"
height="30"
key="staticText-11"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Dest-
ination]]></text>
</staticText>
<staticText>
<reportElement
x="750"
y="0"
width="30"
height="30"
key="staticText-12"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[ISAM Seq.]]></text>
</staticText>
<staticText>
<reportElement
x="700"
y="0"
width="50"
height="30"
key="staticText-13"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[ISAM Id]]></text>
</staticText>
<staticText>
<reportElement
x="670"
y="0"
width="30"
height="30"
key="staticText-14"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Trans. Type]]></text>
</staticText>
<staticText>
<reportElement
x="630"
y="1"
width="40"
height="30"
key="staticText-15"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[CPICC]]></text>
</staticText>
<staticText>
<reportElement
x="510"
y="1"
width="30"
height="30"
key="staticText-16"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Conc. Auth]]></text>
</staticText>
<staticText>
<reportElement
x="480"
y="1"
width="30"
height="30"
key="staticText-17"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Suppl. Info.]]></text>
</staticText>
<staticText>
<reportElement
x="540"
y="1"
width="40"
height="30"
key="staticText-18"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Trans. Seq. No]]></text>
</staticText>
<staticText>
<reportElement
x="580"
y="1"
width="40"
height="30"
key="staticText-19"/>
<box></box>
<textElement verticalAlignment="Bottom">
<font size="8"/>
</textElement>
<text><![CDATA[Rem. Uses]]></text>
</staticText>
</band>
</columnHeader>
Without seeing your JRXML file, the best guess would be one (or combination) of two things:
You do not have the vertical alignment set to Bottom for the fields 1,2,8,9,10.
You do not have the same height set for 1,2,8,9,10.
In addition to those two, you do not have the tops set at the same Top value set for all the elements. Again this is all a best guess without being able to see your JRXML. If it is not one of those you will need to post it, so we can help.
I have tried the stretch type, position type, flot etc.... bottom, asTallest, all sort of thing, it seems nothing worked
what I did was
to change the height of the which around all me header ReportElements from 39 to 20
and each height from 30 to 15
increase some width, make sure they are wide enough
the height 15 kind of forced the texts to stay in one line, give them no space to float,
I feel its a kind of ugly fix, my instinct tells me it must not be the greatest solution, but it works and I need finish it by today. free to post answers, I will accept yours if it works, and much more elegant.
please see the Y Position. It is not same for all heading. you give Y position 0 for 1, 2, 8, 9, 10 and y=1 for remaing item. please make sure all position is same.

How to display page x of y in my jasper report

I am generating the reports using jasperreport-4.5.0.It is generating the report properly.But if i have huge data in my database then the report vl display in different pages.So my requirement is if my report has 12 pages then i want to display page 1 of 12,page 2 of 12,page 3 of 12....like this in my page header band.How can i do this can any one give an idea regarding this.
You can use the evaluationTime="Report" attribute to achieve this.
Consider the following example, we first print "PAGE" then we print the page number using the default evalutaionTime attribute. This will print the current page number, then we print OF and finally the page number with evaluation time set to "report" which will print the total number of pages.
<band height="20">
<elementGroup>
<textField>
<reportElement positionType="FixRelativeToBottom" x="709" y="0" width="53" height="20"/>
<textElement verticalAlignment="Top">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA["PAGE"]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="FixRelativeToBottom" x="762" y="0" width="23" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="FixRelativeToBottom" x="785" y="0" width="29" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA["OF"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement positionType="FixRelativeToBottom" x="814" y="0" width="26" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</elementGroup>
</band>