Jasper Report Crosstab with ArrayList of Data - jasper-reports

I am trying to create Jasper Report with crosstab by writing JRXML with DTOs.
I am trying to create rows dynamic number of chargeCodes and their total. It looks something like this:
jobNo
chargeCodeA
chargeCodeB
Total
jobNoABC
100.10
300.30
400.40
jobNoDEF
200.20
400.40
600.60
In my Java backend, I have DTO which looks like this
class MyDTO {
private String jobNo;
private List <String> chargeCode = new ArrayList <> ();
private List <BigDecimal> chargeCodeTotal = new ArrayList <> ();
}
where the list codeCode contains chargeCodeA, chargeCodeB for jobNoABC
and chargeCodeTotal contains 100.10, 300.30 for jobNoABC also.
In my JRXML, I have this:
<?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="vendorBillingCompletedJobReport" leftMargin="5" rightMargin="5">
<parameter name="lblJobNo" class="java.lang.String" isForPrompting="false"/>
<field name="jobNo" class="java.lang.String"/>
<field name="chargeCode" class="java.util.List"/>
<field name="chargeCodeTotal" class="java.util.List"/>
<summary>
<band height="60">
<crosstab>
<reportElement width="782" y="0" x="0" height="60" />
<rowGroup name="jobNo" width="100" totalPosition="End">
<bucket>
<bucketExpression class="java.util.List">
<![CDATA[$F{jobNo}]]>
</bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents>
<box>
<pen lineColor="black" lineWidth="1"/>
</box>
<textField>
<reportElement width="100" y="0" x="0" height="20" />
<textElement textAlignment="Right" verticalAlignment="Middle" />
<textFieldExpression>
<![CDATA[$V{jobNo}]]>
</textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents>
<box>
<pen lineColor="black" lineWidth="1"/>
</box>
<staticText>
<reportElement x="0" y="0" width="60" height="20" />
<textElement verticalAlignment="Middle" />
<text>TOTAL</text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<columnGroup name="chargeCode" height="20" totalPosition="End">
<bucket>
<bucketExpression class="java.util.List">
$F{chargeCode}
</bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents>
<box>
<pen lineColor="black" lineWidth="1"/>
</box>
<textField isStretchWithOverflow="true">
<reportElement width="60" y="0" x="0" height="20" />
<textElement verticalAlignment="Bottom" />
<textFieldExpression>
<![CDATA[$V{chargeCode}]]>
</textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents>
<box>
<pen lineColor="black" lineWidth="1"/>
</box>
<staticText>
<reportElement width="60" y="0" x="0" height="20" />
<textElement verticalAlignment="Bottom" />
<text>TOTAL</text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<measure name="chargeCodeTotalCount" class="java.math.BigDecimal" calculation="Sum">
<measureExpression>$F{chargeCodeTotal}</measureExpression>
</measure>
<crosstabCell height="20" width="60">
<cellContents backcolor="#FFFFFF">
<box>
<pen lineColor="black" lineWidth="1"/>
</box>
<textField>
<reportElement x="5" y="0" width="55" height="20" />
<textElement textAlignment="Left" verticalAlignment="Bottom" />
<textFieldExpression class="java.math.BigDecimal">
$V{chargeCodeTotalCount}
</textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
</crosstab>
</band>
</summary>
</jasperReport>
But I am getting error:
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Comparable
at org.apache.commons.collections.comparators.ComparableComparator.compare(ComparableComparator.java:91)
I am not sure how to create infinite number of chargeCodes using JRXML.
And I cannot use Dynamic Jasper. I can only think of crosstab. Please help. Thanks.

Related

How to to display list of values in rowgroup in a crosstab?

I'm unable to display list of values in crosstab rowgroup
I have this sample json
{
"header": {
"columnName": [
"Product Store1",
"location"
],
"values": [{
"purchase": {
"name": "bags",
"location": "MainMarket ",
"markets":["1","2","3"]
},
"weekSpend": [{
"weekStartDate": 20181105,
"spend": 100
},
{
"weekStartDate": 20181112,
"spend": 200
}
]
},
{
"purchase": {
"name": "shoes",
"location": "MainMarket ",
"markets":["a","b","c"]
},
"weekSpend": [{
"weekStartDate": 20181105,
"spend": 100
},
{
"weekStartDate": 20181112,
"spend": 200
}
]
}
]
}
i want to show the output of market as row group as list of values Following this post jasper map crosstab crosstabHeaderCell from subdataset different from crosstabdataset
I created crosstab parameter
<crosstabParameter name="listDS" class="net.sf.jasperreports.engine.data.JsonQLDataSource">
<parameterValueExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("purchase.markets")]]></parameterValueExpression>
</crosstabParameter>
then referenced this list in row group like this
<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="listSubDataset" uuid="b7fb45d8-2511-483e-9967-dd7efd283a1b">
<dataSourceExpression><![CDATA[$P{listDS}]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="85" width="70">
<textField>
<reportElement x="0" y="0" width="100" height="30" uuid="672350d1-e69e-4ef3-a9da-c36d66646220"/>
<textFieldExpression><![CDATA[$F{colName}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
but the generated report displays market array as null
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 -->
<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="XTabReport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="33c43d53-f9b3-4cc9-92b2-bedd805d66a9">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="json_crosstab/DataAdapter.xml"/>
<style name="Crosstab_CH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CG" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CT" mode="Opaque" backcolor="#005FB3">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="XTabDS" uuid="9911fa6c-61b7-4952-81bf-4666e3e17fcf">
<field name="weekStartDate" class="java.lang.Integer">
<property name="net.sf.jasperreports.jsonql.field.expression" value="weekStartDate"/>
</field>
<field name="spend" class="java.lang.Integer">
<property name="net.sf.jasperreports.jsonql.field.expression" value="spend"/>
</field>
<field name="name" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.purchase.name"/>
</field>
<field name="location" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.purchase.location"/>
</field>
</subDataset>
<subDataset name="listSubDataset" uuid="01e76955-f29e-4d52-991b-aa0149bfdb37">
<field name="colName" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="[0]"/>
</field>
</subDataset>
<queryString language="jsonql">
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="58">
<staticText>
<reportElement x="140" y="10" width="280" height="30" uuid="c8e3d7ad-eeb0-4cd1-8bef-88874e6921d4"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14"/>
</textElement>
<text><![CDATA[List inside Crosstab]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="30" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="70" splitType="Stretch">
<crosstab>
<reportElement x="0" y="0" width="560" height="70" uuid="79f2afae-ac8b-4442-ac8e-ae1b1f68109f">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.crosstab.style.header" value="Crosstab_CH"/>
<property name="com.jaspersoft.studio.crosstab.style.group" value="Crosstab_CG"/>
<property name="com.jaspersoft.studio.crosstab.style.total" value="Crosstab_CT"/>
<property name="com.jaspersoft.studio.crosstab.style.detail" value="Crosstab_CD"/>
</reportElement>
<crosstabParameter name="listDS" class="net.sf.jasperreports.engine.data.JsonQLDataSource">
<parameterValueExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("purchase.markets")]]></parameterValueExpression>
</crosstabParameter>
<crosstabDataset>
<dataset>
<datasetRun subDataset="XTabDS" uuid="73b2e155-5015-451a-8813-7e2ed2f731fb">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("..values..weekSpend.*")]]></dataSourceExpression>
</datasetRun>
</dataset>
</crosstabDataset>
<crosstabHeaderCell>
<cellContents>
<componentElement>
<reportElement x="0" y="0" width="180" height="30" isPrintWhenDetailOverflows="true" uuid="412c6db7-0cfa-4025-80cd-8c450f9eab96">
<property name="net.sf.jasperreports.export.headertoolbar.table.name" value=""/>
</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="Horizontal">
<datasetRun subDataset="listSubDataset" uuid="a911c80f-a0b3-4395-bbd7-2c52c67585d3">
<dataSourceExpression><![CDATA[$P{listDS}]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="30" width="90">
<textField>
<reportElement x="0" y="0" width="90" height="30" isPrintWhenDetailOverflows="true" uuid="168fd030-81cf-4b80-9766-6f4637c779ec"/>
<box>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
</box>
<textElement>
<paragraph leftIndent="3" spacingBefore="3"/>
</textElement>
<textFieldExpression><![CDATA[$F{colName}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</cellContents>
</crosstabHeaderCell>
<rowGroup name="name" width="90" totalPosition="End">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{name}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="e8aa37d7-0921-40a6-8aca-1cccae61d26d"/>
<textElement>
<paragraph leftIndent="3" spacingBefore="3"/>
</textElement>
<textFieldExpression><![CDATA[$V{name}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents/>
</crosstabTotalRowHeader>
</rowGroup>
<rowGroup name="location" width="90" totalPosition="End">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{location}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="86107a55-79be-4170-a2ee-b2a0ae5315e2"/>
<textElement>
<paragraph leftIndent="3" spacingBefore="3"/>
</textElement>
<textFieldExpression><![CDATA[$V{location}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents/>
</crosstabTotalRowHeader>
</rowGroup>
<columnGroup name="weekStartDate" height="30" totalPosition="End">
<bucket class="java.lang.Integer">
<bucketExpression><![CDATA[$F{weekStartDate}]]></bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="90" height="30" uuid="c65fb64a-d89b-4cc3-be28-d76624cb3d93"/>
<textElement>
<paragraph leftIndent="3" spacingBefore="3"/>
</textElement>
<textFieldExpression><![CDATA[$V{weekStartDate}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents/>
</crosstabTotalColumnHeader>
</columnGroup>
<measure name="spend_MEASURE" class="java.lang.Integer">
<measureExpression><![CDATA[$F{spend}]]></measureExpression>
</measure>
<crosstabCell width="90" height="20">
<cellContents mode="Opaque" style="Crosstab_CD">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="efb4b6dd-d9d3-4520-a94e-c0010a572b29"/>
<textElement>
<paragraph leftIndent="3" spacingBefore="3"/>
</textElement>
<textFieldExpression><![CDATA[$V{spend_MEASURE}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell height="20" columnTotalGroup="weekStartDate">
<cellContents/>
</crosstabCell>
<crosstabCell width="90" height="0" rowTotalGroup="location">
<cellContents/>
</crosstabCell>
<crosstabCell height="0" rowTotalGroup="location" columnTotalGroup="weekStartDate">
<cellContents/>
</crosstabCell>
<crosstabCell width="90" height="20" rowTotalGroup="name">
<cellContents/>
</crosstabCell>
<crosstabCell height="20" rowTotalGroup="name" columnTotalGroup="weekStartDate">
<cellContents/>
</crosstabCell>
</crosstab>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
excepted output is
but actual output is

List component displays only the first row

In my JasperReport's report only the first row of my collection gets displayed. Here is the relevant code.
The entity
public class LegendEntity implements Serializable{
private String label;
private Image bufferedImage;
public LegendEntity() {
}
public LegendEntity(String label) {
this.label = label;
}
public LegendEntity(String label,Image bufferedImage) {
this.label = label;
this.bufferedImage = bufferedImage;
}
//getters-setters
Preparing the datasource:
List<MyEntity> myEntitiesList = new ArrayList<>();
//filling the list
JRBeanCollectionDataSource entityDS= new JRBeanCollectionDataSource(myEntitiesList ,false);
report.getReportParameters().put("ENTITY_DATASOURCE", entityDS);
The jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ... name="SampleReport" printOrder="Horizontal" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
<subDataset name="LegendDataset" uuid="e0d72aca-6fd5-4935-b57f-ff5a436f2afb">
<field name="label" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="bufferedImage" class="java.awt.Image"/>
</subDataset>
<parameter name="P_MAP_SCALE_STR" class="java.lang.String"/>
<parameter name="ENTITY_DATASOURCE" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<detail>
<band height="842" splitType="Stretch">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<frame>
<reportElement x="298" y="635" width="298" height="206" uuid="e807b35a-857c-43ba-a080-13f422eb1456"/>
<componentElement>
<reportElement x="11" y="11" width="275" height="186" uuid="d6f579d3-75de-4745-8f94-c974d2e697a0"/>
<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="LegendDataset" uuid="ee194811-e7e5-4102-83ff-b150901d73c9">
<dataSourceExpression><![CDATA[$P{ENTITY_DATASOURCE}]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="186" width="275">
<staticText>
<reportElement x="10" y="10" width="130" height="20" uuid="4260f10d-ee62-4cf6-8023-d0dc2266f4dd"/>
<textElement textAlignment="Center"/>
<text><![CDATA[ENTITY LABEL]]></text>
</staticText>
<staticText>
<reportElement x="150" y="10" width="100" height="20" uuid="88135c50-3c17-4b0f-b7e5-b05987f98b02"/>
<textElement textAlignment="Center"/>
<text><![CDATA[ENTITY SYMBOL]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="10" y="31" width="130" height="18" uuid="30885d06-38db-4b1c-a312-616a60ee1c42"/>
<textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
</textField>
<image>
<reportElement x="150" y="31" width="100" height="18" uuid="0020adca-acad-4915-9f0d-88d75e4897c7"/>
<imageExpression><![CDATA[$F{bufferedImage}]]></imageExpression>
</image>
</jr:listContents>
</jr:list>
</componentElement>
</frame>
<staticText>
<reportElement x="30" y="600" width="80" height="18" uuid="6c1afd65-a8d4-4e3f-9a56-d09abe7ec904"/>
<textElement textAlignment="Right">
<font fontName="DejaVu Sans" size="9" isBold="true"/>
</textElement>
<text><![CDATA[Ölçek: 1/]]></text>
</staticText>
<textField>
<reportElement positionType="Float" x="110" y="600" width="100" height="18" uuid="6360a545-63af-48cc-987d-d828c24a3b2a"/>
<textElement>
<font fontName="DejaVu Sans" size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{P_MAP_SCALE_STR}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
And on the report only the first entity's label and symbol is displayed. What am I missing?
Debugging already done and I am sure that 1+ entities are present in the list.
The whole JRXML here .
You can try to put variables in white zone in table. Not in blue/header zone.
It works for me.
I have noticed at least 2 problems in your main JRXML:
Setting printOrder="Horizontal" at the report level may prevent proper elements overflow. Try reverting to printOrder="Vertical" or remove the attribute completely.
There is too much whitespace inside the list element that would force overflow. You should not have white space after the last elements.

jasper report textfield height is not dynamic [duplicate]

I am using jasper report as reporting tool in my application. And I am wondering how can i wrap the long text by expanding the reportElement dynamically into vertical direction ( expanding the row size, not column width). Or Is there any way to achieve this? My approach below is truncating the long text "Some very long name". Can you please give me some suggestions?
Output :
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.view.JasperViewer;
public class JrUtils {
public static void showJrReport(List objectList, String fileName, String title, Map parameters) {
try {
File f = new File(fileName);
JasperDesign jasperDesign = JRXmlLoader.load(f.getAbsolutePath());
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(objectList);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, ds);
JasperViewer jv = new JasperViewer(jasperPrint, false);
jv.setTitle(title);
jv.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
List<Person> pList = new ArrayList<Person>();
Person p1 = new Person();
p1.setPersonName("Some Name ");
p1.setAddress("Nepal - Address Fits Here");
Person p2 = new Person();
p2.setPersonName("Some very long name");
p2.setAddress("Nepal - Address Fits Here");
pList.add(p1);
pList.add(p2);
showJrReport(pList, "testReport.jrxml", "Test Report", new HashMap<Object, Object>());
}
}
Jasper Report JrXML file - testReport.jrxml :
<?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="report name" pageWidth="250" pageHeight="400" columnWidth="210" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="2.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<field name="personName" class="java.lang.String"/>
<field name="address" class="java.lang.String"/>
<columnHeader>
<band height="23" splitType="Stretch">
<rectangle>
<reportElement x="0" y="0" width="88" height="23"/>
</rectangle>
<rectangle>
<reportElement x="88" y="0" width="122" height="23"/>
</rectangle>
<staticText>
<reportElement x="0" y="0" width="88" height="23"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Name]]></text>
</staticText>
<staticText>
<reportElement x="88" y="0" width="122" height="23"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Address]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="21" splitType="Stretch">
<rectangle>
<reportElement x="0" y="0" width="88" height="21"/>
</rectangle>
<textField>
<reportElement x="0" y="0" width="88" height="21"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{personName}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement x="88" y="0" width="122" height="21"/>
</rectangle>
<textField>
<reportElement x="88" y="0" width="122" height="21"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
I found the answer myself :
I did some extra research about the properties of textField and rectangle components. And found that I need to set the following properties.
For rectangle :
<rectangle>
<reportElement stretchType="RelativeToBandHeight" ... />
</rectangle>
For textField :
<textField isStretchWithOverflow="true">
...
</textField>
Output as expected :
The <detail> ...</detail> section after correction :
<detail>
<band height="21" splitType="Stretch">
<rectangle>
<reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="88" height="21"/>
</rectangle>
<textField isStretchWithOverflow="true">
<reportElement x="2" y="0" width="84" height="21"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{personName}]]></textFieldExpression>
</textField>
<rectangle>
<reportElement stretchType="RelativeToBandHeight" x="88" y="0" width="122" height="21"/>
</rectangle>
<textField isStretchWithOverflow="true">
<reportElement x="90" y="0" width="118" height="21"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
</band>
</detail>
UPDATE
You can also set property net.sf.jasperreports.print.keep.full.text to true to achieve that across your all reports.
Also you can make the truncation elegant by using the following properties set to the textfield. Check this sample
net.sf.jasperreports.text.truncate.at.char
net.sf.jasperreports.text.truncate.suffix
net.sf.jasperreports.print.keep.full.text
Go to the Text Field Properties then set Text Adjust to StretchHeight.

How to set Page footer to the bottom of the every page in Jasper Reports?

For export the page footer are always at the bottom of the page.
But in Print preview the page footer comes immediately after the detail band.
I want the page footer to appear always at the bottom of the page , irrespective of detail band height.
Below is the xml,
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Created with Jaspersoft Studio version 6.0.3.final using JasperReports Library version 6.0.3 -->
<!-- 2015-03-12T14:09:48 -->
<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="Listing Report" pageWidth="1385" pageHeight="922" orientation="Landscape" columnWidth="1335" leftMargin="25" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.5" />
<property name="ireport.x" value="0" />
<property name="ireport.y" value="0" />
<template>
<![CDATA[$P{templatePath}]]>
</template>
<style name="Crosstab Data Text" />
<style name="Zebra" mode="Opaque">
<conditionalStyle> <conditionExpression><![CDATA[$V {
REPORT_COUNT
}
%2==1]]></conditionExpression> <style backcolor="#F0F0F0"/> </conditionalStyle>
</style>
<parameter name="appointmentid" class="java.lang.String" />
<parameter name="reportsetid" class="java.lang.Object" />
<parameter name="savedreportid" class="java.lang.Object" />
<parameter name="dbtablename" class="java.lang.String" isForPrompting="false">
<parameterDescription>
<![CDATA[appointmentlistingseedreport]]>
</parameterDescription>
</parameter>
<parameter name="partialInlineQuery" class="java.lang.String" isForPrompting="false">
<parameterDescription>
<!-----------------Query--------------------->
</parameterDescription>
</parameter>
<parameter name="dynamicdbtablename" class="java.lang.String" isForPrompting="false">
<parameterDescription>
<![CDATA[appointmentlistingdynamicdata]]>
</parameterDescription>
</parameter>
<parameter name="templatePath" class="java.lang.String" />
<queryString>
<!--Query String------------------>
</queryString>
<field name="reportsetid" class="java.lang.Object" />
<field name="savedreportid" class="java.lang.Object" />
<field name="organizationname" class="java.lang.String" />
<field name="duration" class="java.lang.Integer" />
<field name="appointmenttypename" class="java.lang.String" />
<field name="personname" class="java.lang.String" />
<field name="appointmentstatus" class="java.lang.String" />
<field name="appointmentdate" class="java.sql.Date" />
<field name="location" class="java.lang.String" />
<field name="ordername" class="java.lang.String" />
<field name="ordertype" class="java.lang.String" />
<field name="orderstatus" class="java.lang.String" />
<field name="resultstatus" class="java.lang.String" />
<field name="resourcename" class="java.lang.String" />
<field name="appointmentstarttime" class="java.sql.Time" />
<variable name="GrandTotal_Count" class="java.math.BigDecimal" calculation="Count">
<variableExpression>
<![CDATA[$F{reportsetid}]]>
</variableExpression>
</variable>
<variable name="GrandTotal_Variable" class="java.lang.String" calculation="Count">
<variableExpression>
<![CDATA["Grand Total ( " + $V{GrandTotal_Count} + ")"]]>
</variableExpression>
</variable>
<variable name="organizationname_Count" class="java.math.BigDecimal" resetType="Group" resetGroup="organizationname" calculation="Count">
<variableExpression>
<![CDATA[$F{organizationname}]]>
</variableExpression>
</variable>
<variable name="organizationname_Variable" class="java.lang.String" resetType="Group" resetGroup="organizationname" calculation="Count">
<variableExpression>
<![CDATA["Total for " + (($F{organizationname} != null) ? $F{organizationname} : "") + " " + "(" + $V{organizationname_Count} + ")"]]>
</variableExpression>
</variable>
<variable name="location_Count" class="java.math.BigDecimal" resetType="Group" resetGroup="location" calculation="Count">
<variableExpression>
<![CDATA[$F{location}]]>
</variableExpression>
</variable>
<variable name="location_Variable" class="java.lang.String" resetType="Group" resetGroup="location" calculation="Count">
<variableExpression>
<![CDATA["Total for " + (($F{location} != null) ? $F{location} : "") + " " + "(" + $V{location_Count} + ")"]]>
</variableExpression>
</variable>
<variable name="resourcename_Count" class="java.math.BigDecimal" resetType="Group" resetGroup="resourcename" calculation="Count">
<variableExpression>
<![CDATA[$F{resourcename}]]>
</variableExpression>
</variable>
<variable name="resourcename_Variable" class="java.lang.String" resetType="Group" resetGroup="resourcename" calculation="Count">
<variableExpression>
<![CDATA["Total for " + (($F{resourcename} != null) ? $F{resourcename} : "") + " " + "(" + $V{resourcename_Count} + ")"]]>
</variableExpression>
</variable>
<group name="FooterGrandTotal">
<groupFooter>
<band height="20">
<textField>
<reportElement x="0" y="0" width="0" height="20" uuid="a23e46f3-b798-42ec-816e-c3e0c76ee7f6" />
<textElement>
<font size="17" isBold="true" />
</textElement>
<textFieldExpression>
<![CDATA[(($V{GrandTotal_Variable} != null) ? $V{GrandTotal_Variable} : "")]]>
</textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<group name="organizationname" isStartNewPage="true">
<groupExpression>
<![CDATA[(($F{organizationname} != null) ? ($F{organizationname} +" "+ "<style isItalic='true' forecolor='#aaaaaa'>Org</style> ") :"Org")]]>
</groupExpression>
<groupHeader>
<band height="20">
<textField>
<reportElement style="Zebra" x="0" y="0" width="1335" height="20" forecolor="#333333" uuid="cf936d24-cfb0-44ff-a601-e4bcba0a1cf7" />
<box leftPadding="15" />
<textElement markup="styled">
<font size="17" isBold="true" />
</textElement>
<textFieldExpression>
<![CDATA[(($F{organizationname} != null) ? ($F{organizationname} +" "+ "<style isItalic='true' forecolor='#aaaaaa'>Org</style> ") :"Org")]]>
</textFieldExpression>
</textField>
</band>
</groupHeader>
<groupFooter>
<band height="20">
<textField>
<reportElement style="Zebra" x="0" y="0" width="1335" height="20" forecolor="#333333" uuid="cf936d24-cfb0-44ff-a601-e4bcba0a1cf7" />
<box leftPadding="15" />
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<textFieldExpression>
<![CDATA[(($V{organizationname_Variable} != null) ? $V{organizationname_Variable} : "")]]>
</textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<group name="location">
<groupExpression>
<![CDATA[(($F{location} != null) ? ($F{location} +" "+ "<style isItalic='true' forecolor='#aaaaaa'>Location</style> ") :"Location")]]>
</groupExpression>
<groupHeader>
<band height="20">
<textField>
<reportElement style="Zebra" x="0" y="0" width="1335" height="20" forecolor="#333333" uuid="0f1dc658-577b-4a1a-a937-b21af77454d4" />
<box leftPadding="40" />
<textElement markup="styled">
<font size="17" isBold="true" />
</textElement>
<textFieldExpression>
<![CDATA[(($F{location} != null) ? ($F{location} +" "+ "<style isItalic='true' forecolor='#aaaaaa'>Location</style> ") :"Location")]]>
</textFieldExpression>
</textField>
</band>
</groupHeader>
<groupFooter>
<band height="20">
<textField>
<reportElement style="Zebra" x="0" y="0" width="1335" height="20" forecolor="#333333" uuid="0f1dc658-577b-4a1a-a937-b21af77454d4" />
<box leftPadding="40" />
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<textFieldExpression>
<![CDATA[(($V{location_Variable} != null) ? $V{location_Variable} : "")]]>
</textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<group name="resourcename">
<groupExpression>
<![CDATA[(($F{resourcename} != null) ? ($F{resourcename} +" "+ "<style isItalic='true' forecolor='#aaaaaa'>Resource</style> ") :"Resource")]]>
</groupExpression>
<groupHeader>
<band height="20">
<textField>
<reportElement style="Zebra" x="0" y="0" width="1335" height="20" forecolor="#333333"/>
<box leftPadding="65" />
<textElement markup="styled">
<font size="17" isBold="true" />
</textElement>
<textFieldExpression>
<![CDATA[(($F{resourcename} != null) ? ($F{resourcename} +" "+ "<style isItalic='true' forecolor='#aaaaaa'>Resource</style> ") :"Resource")]]>
</textFieldExpression>
</textField>
</band>
</groupHeader>
<groupFooter>
<band height="20">
<textField>
<reportElement style="Zebra" x="0" y="0" width="1335" height="20" forecolor="#333333" uuid="613e4649-a0be-402b-b641-6792d681a3fd" />
<box leftPadding="65" />
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<textFieldExpression>
<![CDATA[(($V{resourcename_Variable} != null) ? $V{resourcename_Variable} : "")]]>
</textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<title>
<band height="24" splitType="Stretch" />
</title>
<pageHeader>
<band height="100">
<textField>
<reportElement x="0" y="0" width="1335" height="20" forecolor="#999999" uuid="07f143b8-4615-48bf-a984-3f5d9f1b7fdb" />
<textElement textAlignment="Left">
<font size="17" isBold="true" />
</textElement>
<textFieldExpression>
<![CDATA[(("GENHEALTH FAMILY PRACTICE ASSOCIATES (GFPA)" != null) ? "GENHEALTH FAMILY PRACTICE ASSOCIATES (GFPA)" : "")]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="20" width="1335" height="20" forecolor="#999999" uuid="548c383a-181b-4a5e-9773-95bec6028b2f" />
<textElement textAlignment="Left">
<font size="17" isBold="false" isItalic="true" />
</textElement>
<textFieldExpression>
<![CDATA[(("Appointment List" != null) ? "Appointment List" : "")]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="40" width="1335" height="20" forecolor="#999999" uuid="9a238441-512f-4e24-84c4-d0c6f78a912a" />
<textElement textAlignment="Left">
<font size="17" isBold="false" />
</textElement>
<textFieldExpression>
<![CDATA[(("Appointment Date : is not : 03/12/2015" != null) ? "Appointment Date : is not : 03/12/2015" : "")]]>
</textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="25" splitType="Stretch">
<staticText>
<reportElement style="table-header" x="0" y="0" width="210" height="20" uuid="2d0b156b-95f8-487c-bb7d-09e729e3e364">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<box leftPadding="85" />
<textElement verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<text>
<![CDATA[Appt Type]]>
</text>
</staticText>
<staticText>
<reportElement style="table-header" x="210" y="0" width="125" height="20" uuid="e059ad06-5f5d-4056-9217-a21fa154640e">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<text>
<![CDATA[Appt Date]]>
</text>
</staticText>
<staticText>
<reportElement style="table-header" x="335" y="0" width="125" height="20" uuid="3890f6d6-0d75-4bda-90ca-97cb7a7d4333">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<text>
<![CDATA[Appt Time]]>
</text>
</staticText>
<staticText>
<reportElement style="table-header" x="460" y="0" width="125" height="20" uuid="9f7d46ea-c2ee-4a6f-ba73-57e90ed1045b">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<text>
<![CDATA[Appt Dur]]>
</text>
</staticText>
<staticText>
<reportElement style="table-header" x="585" y="0" width="125" height="20" uuid="e4d430ab-b03d-4f18-8779-c8d37e30e21b">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<text>
<![CDATA[Pat Name]]>
</text>
</staticText>
<staticText>
<reportElement style="table-header" x="710" y="0" width="125" height="20" uuid="3c06f694-8e55-4565-af1a-7386ccee9422">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<text>
<![CDATA[Appt Sts]]>
</text>
</staticText>
<staticText>
<reportElement style="table-header" x="835" y="0" width="125" height="20" uuid="434fe607-d680-4fef-b67d-0cc18957f6f9">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<text>
<![CDATA[Order Name]]>
</text>
</staticText>
<staticText>
<reportElement style="table-header" x="960" y="0" width="125" height="20" uuid="a2f59de7-7964-4d52-8beb-e9f4e3c8ca03">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<text>
<![CDATA[Order Type]]>
</text>
</staticText>
<staticText>
<reportElement style="table-header" x="1085" y="0" width="125" height="20" uuid="4b7703eb-2426-4574-bb23-66b35dadaa03">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<text>
<![CDATA[Order Status]]>
</text>
</staticText>
<staticText>
<reportElement style="table-header" x="1210" y="0" width="125" height="20" uuid="1add3ebc-c688-41af-831c-efba8ee67b92">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="true" />
</textElement>
<text>
<![CDATA[Result Status]]>
</text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement style="Zebra" x="0" y="0" width="210" height="20" uuid="2ae4a4f2-473e-42a9-8055-c02309813c9a">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<box leftPadding="85" />
<textElement verticalAlignment="Middle">
<font size="17" isBold="false" />
</textElement>
<textFieldExpression>
<![CDATA[(($F{appointmenttypename} != null) ? $F{appointmenttypename} : "")]]>
</textFieldExpression>
</textField>
<textField>
<reportElement style="Zebra" x="210" y="0" width="125" height="20" uuid="d9a4e371-73f3-4540-a135-952dacb1d937">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="false" />
</textElement>
<textFieldExpression>
<![CDATA[$P{REPORT_SCRIPTLET}.formatDate($F{appointmentdate})]]>
</textFieldExpression>
</textField>
<textField>
<reportElement style="Zebra" x="335" y="0" width="125" height="20" uuid="b293699a-e8cb-4dd4-a878-1fc5082f686d">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="false" />
</textElement>
<textFieldExpression>
<![CDATA[$P{REPORT_SCRIPTLET}.formatTime($F{appointmentstarttime})]]>
</textFieldExpression>
</textField>
<textField>
<reportElement style="Zebra" x="460" y="0" width="125" height="20">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<box rightPadding="10" />
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="17" isBold="false" />
<paragraph lineSpacing="1_1_2" rightIndent="20" />
</textElement>
<textFieldExpression>
<![CDATA[(($F{duration} != null) ? $F{duration} : "")]]>
</textFieldExpression>
</textField>
<textField>
<reportElement style="Zebra" x="585" y="0" width="125" height="20">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="false" />
</textElement>
<textFieldExpression>
<![CDATA[(($F{personname} != null) ? $F{personname} : "")]]>
</textFieldExpression>
</textField>
<textField>
<reportElement style="Zebra" x="710" y="0" width="125" height="20">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="false" />
</textElement>
<textFieldExpression>
<![CDATA[(($F{appointmentstatus} != null) ? $F{appointmentstatus} : "")]]>
</textFieldExpression>
</textField>
<textField>
<reportElement style="Zebra" x="835" y="0" width="125" height="20">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="false" />
</textElement>
<textFieldExpression>
<![CDATA[(($F{ordername} != null) ? $F{ordername} : "")]]>
</textFieldExpression>
</textField>
<textField>
<reportElement style="Zebra" x="960" y="0" width="125" height="20">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="false" />
</textElement>
<textFieldExpression>
<![CDATA[(($F{ordertype} != null) ? $F{ordertype} : "")]]>
</textFieldExpression>
</textField>
<textField>
<reportElement style="Zebra" x="1085" y="0" width="125" height="20">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="false" />
</textElement>
<textFieldExpression>
<![CDATA[(($F{orderstatus} != null) ? $F{orderstatus} : "")]]>
</textFieldExpression>
</textField>
<textField>
<reportElement style="Zebra" x="1210" y="0" width="125" height="20">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true" />
<property name="net.sf.jasperreports.text.truncate.suffix" value="..." />
</reportElement>
<textElement verticalAlignment="Middle">
<font size="17" isBold="false" />
</textElement>
<textFieldExpression>
<![CDATA[(($F{resultstatus} != null) ? $F{resultstatus} : "")]]>
</textFieldExpression>
</textField>
</band>
</detail>
<pageFooter>
<band height="100">
<textField>
<reportElement x="890" y="20" width="445" height="20"/>
<textElement textAlignment="Right">
<font size="17" isBold="true" />
</textElement>
<textFieldExpression>
<![CDATA[(("Confidential" != null) ? "Confidential" : "")]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="20" width="445" height="20"/>
<textElement textAlignment="Left">
<font size="17" isBold="true" />
</textElement>
<textFieldExpression>
<![CDATA[(("Prepared at 01:16 PM CDT,March 12, 2015" != null) ? "Prepared at 01:16 PM CDT,March 12, 2015" : "")]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x="445" y="20" width="222" height="20"/>
<textElement textAlignment="Right">
<font size="17" isBold="true" />
</textElement>
<textFieldExpression>
<![CDATA[(("Page "+$V{PAGE_NUMBER}+" of" != null) ? "Page "+$V{PAGE_NUMBER}+" of" : "")]]>
</textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="667" y="20" width="222" height="20"/>
<textElement textAlignment="Left">
<font size="17" isBold="true" />
</textElement>
<textFieldExpression>
<![CDATA[((" " + $V{PAGE_NUMBER} != null) ? " " + $V{PAGE_NUMBER} : "")]]>
</textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="35" splitType="Prevent" />
</summary>
<noData>
<band height="20">
<staticText>
<reportElement x="206" y="0" width="174" height="20"/>
<textElement textAlignment="Center">
<font size="14" isBold="true" />
</textElement>
<text>
<![CDATA[No Data Found]]>
</text>
</staticText>
</band>
</noData>
</jasperReport>
Are you sure its page footer? because page footer will always be at the bottom of page. Try decreasing the height, may be the top of your page footer is at middle of the page. And one more thing, page footer will always be after detail section unless you don't have a column footer in between.
I just facing same issue, It seems that pageFooter extends its height to fill all left space if exists.
Try to change all your page footer elements position to "FixRelativeToBottom"
<reportElement positionType="FixRelativeToBottom" ... >
Or create a frame with this position type and then you put all your elements inside

Unable to print borders for empty cells in PDF via JasperReports

I am constructing a 'table' by having cells next to each other and they all have borders. But I have a problem where the borders won't show if the cell for workcode text doesn't have a value.
This is my jrxml - (it is a subreport so I have a extra dataset there, and workcodeText is handled this way because I don't know how many workcode text nodes I will have in the xml data.)
<?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="estimate-subreport" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" scriptletClass="com.cybage.mo.CostCalculation" uuid="2df6e224-aab9-42e3-a97c-aa614b05982c">
<property name="ireport.zoom" value="1.5"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="Normal-Text-Small" hAlign="Left" vAlign="Top" fontName="Calibri" fontSize="9" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false">
<box leftPadding="1" rightPadding="1"/>
</style>
<style name="Normal-Text-Small-with-borders" style="Normal-Text-Small" hAlign="Left" vAlign="Top" fontName="Calibri" fontSize="9" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false">
<box leftPadding="1" rightPadding="1">
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Normal-Text-Small-bold" style="Normal-Text-Small" hAlign="Left" vAlign="Top" fontName="Calibri" fontSize="9" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false">
<box leftPadding="1" rightPadding="1"/>
</style>
<style name="Normal-Text-Small-bold-with-borders" style="Normal-Text-Small-bold" hAlign="Left" vAlign="Top" fontName="Calibri" fontSize="9" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false">
<box leftPadding="1" rightPadding="1">
<pen lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="WorkcodeText" uuid="3615899a-9e63-45db-a26e-d4e6d1670f84">
<queryString language="xPath">
<![CDATA[/MCSResponse/EstimateDisplayResponse/CategoryDetail/WorkcodeDetail/WorkcodeText]]>
</queryString>
<field name="WorkcodeText" class="java.lang.String">
<fieldDescription><![CDATA[child::text()]]></fieldDescription>
</field>
<field name="last_wct" class="java.lang.String">
<fieldDescription><![CDATA[../WorkcodeText[last()]]]></fieldDescription>
</field>
<field name="WorkcodeAmount" class="java.lang.String">
<fieldDescription><![CDATA[/MCSResponse/EstimateDisplayResponse/CategoryDetail/WorkcodeDetail/WorkcodeAmount]]></fieldDescription>
</field>
<variable name="varWorkcodeText" class="java.lang.String">
<variableExpression><![CDATA[$V{varWorkcodeText}+($F{WorkcodeText} != null? $F{WorkcodeText}:" test ")]]></variableExpression>
<initialValueExpression><![CDATA[""]]></initialValueExpression>
</variable>
</subDataset>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["D:\\iReport\\Saquib\\Single_Estimate_Report\\Test\\"]]></defaultValueExpression>
</parameter>
<queryString language="xPath">
<![CDATA[CategoryDetail/WorkcodeDetail]]>
</queryString>
<field name="Workcode" class="java.lang.String">
<fieldDescription><![CDATA[Workcode]]></fieldDescription>
</field>
<field name="WorkcodeName" class="java.lang.String">
<fieldDescription><![CDATA[WorkcodeName]]></fieldDescription>
</field>
<field name="ExtraWorkcodeName" class="java.lang.String">
<fieldDescription><![CDATA[ExtraWorkcodeName]]></fieldDescription>
</field>
<field name="WorkcodeAmount" class="java.lang.String">
<fieldDescription><![CDATA[WorkcodeAmount]]></fieldDescription>
</field>
<field name="WorkcodeText" class="java.lang.String">
<fieldDescription><![CDATA[WorkcodeText]]></fieldDescription>
</field>
<field name="ItemDetail" class="java.lang.String">
<fieldDescription><![CDATA[ItemDetail]]></fieldDescription>
</field>
<detail>
<band height="15">
<componentElement>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="150" y="0" width="300" height="15" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="6b4ddd03-9978-4f83-a247-3fff22149cb1"/>
<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="WorkcodeText" uuid="7aeae23c-e1fe-4470-9ee5-98f84cd82159">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//WorkcodeText")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="15" width="300">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="Normal-Text-Small-with-borders" positionType="Float" stretchType="RelativeToTallestObject" mode="Transparent" x="0" y="0" width="300" height="15" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" forecolor="#0000FF" uuid="03dd8f13-7604-41be-9155-ae02aa44500e">
<printWhenExpression><![CDATA[$F{WorkcodeText}.equals($F{last_wct})]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Top">
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA[$V{varWorkcodeText}.replaceAll( "<nl>", "\n" )]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement style="Normal-Text-Small-with-borders" stretchType="RelativeToTallestObject" x="0" y="0" width="20" height="15" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true" forecolor="#3333FF" uuid="8c9080c7-cb77-430c-be2e-b6252f9b8d8e"/>
<textElement verticalAlignment="Top">
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{Workcode}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
<reportElement style="Normal-Text-Small-with-borders" stretchType="RelativeToTallestObject" x="450" y="0" width="105" height="15" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true" forecolor="#3300FF" uuid="ebdd4d26-bc29-4546-a9b5-24f2be132aa8"/>
<textElement textAlignment="Right">
<font size="9"/>
<paragraph lineSpacing="Single"/>
</textElement>
<textFieldExpression><![CDATA[($F{WorkcodeAmount}==""||$F{WorkcodeAmount}==null)?0.00:Float.valueOf($F{WorkcodeAmount})/100]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement style="Normal-Text-Small-with-borders" stretchType="RelativeToTallestObject" x="20" y="0" width="130" height="15" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true" forecolor="#3333FF" uuid="f5fcc495-f401-4498-ac71-7352581cde59"/>
<textElement verticalAlignment="Top">
<font size="9"/>
<paragraph lineSpacing="Single"/>
</textElement>
<textFieldExpression><![CDATA[$F{WorkcodeName}]]></textFieldExpression>
</textField>
</band>
</detail>
This is the XML I am testing with:
<?xml version="1.0" encoding="UTF-8"?>
<CategoryDetail>
<CategoryCode>1</CategoryCode>
<CategoryName>EXTERNAL CREATIVE</CategoryName>
<CategoryTotalName>TOTAL EXTERNAL CREAT</CategoryTotalName>
<CategoryType>1</CategoryType>
<CategoryStatus>YNNYN</CategoryStatus>
<WorkcodeDetail>
<WorkcodeCategory>1</WorkcodeCategory>
<Workcode>1B</Workcode>
<WorkcodeName>VISUALS</WorkcodeName>
<WorkcodeCommissionRate>150000</WorkcodeCommissionRate>
<WorkcodeFlags>NNNNNNNN</WorkcodeFlags>
<ExtraWorkcodeName>Concept and Development</ExtraWorkcodeName>
<WorkcodeType>C</WorkcodeType>
<WorkcodeEstimateCheck>Y</WorkcodeEstimateCheck>
</WorkcodeDetail>
<WorkcodeDetail>
<WorkcodeCategory>1</WorkcodeCategory>
<Workcode>1C</Workcode>
<WorkcodeName>COPY WRITING</WorkcodeName>
<WorkcodeCommissionRate>150000</WorkcodeCommissionRate>
<WorkcodeFlags>NNNNNNNN</WorkcodeFlags>
<ExtraWorkcodeName>Visualisation/Finished Art/Lasers</ExtraWorkcodeName>
<WorkcodeType>C</WorkcodeType>
<WorkcodeEstimateCheck>Y</WorkcodeEstimateCheck>
</WorkcodeDetail>
<WorkcodeDetail>
<WorkcodeCategory>1</WorkcodeCategory>
<Workcode>1E</Workcode>
<WorkcodeName>PHOTOGRAPHY</WorkcodeName>
<WorkcodeAmount>500</WorkcodeAmount>
<WorkcodeCommissionAmount>75</WorkcodeCommissionAmount>
<WorkcodeCommissionRate>150000</WorkcodeCommissionRate>
<WorkcodeFlags>NNNNNNNN</WorkcodeFlags>
<ExtraWorkcodeName>Setting</ExtraWorkcodeName>
<WorkcodeType>C</WorkcodeType>
<WorkcodeEstimateCheck>Y</WorkcodeEstimateCheck>
<WorkcodeText>Jaspersoft was originally called Panscopic, and was founded by Al Campa, CEO, and Raj Bhargava, VP of Products in 2001. Panscopic raised $23M from Doll Capital, Discovery Ventures, Morgenthaler Ventures, and Partech. In 2004 Panscopic teamed up with</WorkcodeText>
<WorkcodeText> Teodor Danciu,[7] acquired the intellectual property of JasperReports, and changed the name of the company to Jaspersoft. Brian Gentile became CEO in 2007.<nl><nl>Jaspersoft provides commercial software around the JasperReports product, and negotiat</WorkcodeText>
<WorkcodeText>e contracts with software developers that wish to embed the JasperReports engine into a closed source product.<nl><nl>Jaspersoft's main related product is JasperReports Server, a Java EE web application that provides advanced report server capabiliti</WorkcodeText>
<WorkcodeText>es such as report scheduling and permissions. It is available under an open source license for use in conjunction with open source infrastructure such as MySQL and JBoss, or a commercial license for enterprise deployments involving commercial databas</WorkcodeText>
<WorkcodeText>es and application servers.</WorkcodeText>
</WorkcodeDetail>
<WorkcodeDetail>
<WorkcodeCategory>1</WorkcodeCategory>
<Workcode>1F</Workcode>
<WorkcodeName>ILLUSTRATIONS</WorkcodeName>
<WorkcodeCommissionRate>150000</WorkcodeCommissionRate>
<WorkcodeFlags>NNNNNNNN</WorkcodeFlags>
<ExtraWorkcodeName>Photography</ExtraWorkcodeName>
<WorkcodeType>C</WorkcodeType>
<WorkcodeEstimateCheck>Y</WorkcodeEstimateCheck>
</WorkcodeDetail>
<WorkcodeDetail>
<WorkcodeCategory>1</WorkcodeCategory>
<Workcode>1G</Workcode>
<WorkcodeName>MODEL FEES</WorkcodeName>
<WorkcodeCommissionRate>150000</WorkcodeCommissionRate>
<WorkcodeFlags>NNNNNNNN</WorkcodeFlags>
<ExtraWorkcodeName>Models</ExtraWorkcodeName>
<WorkcodeType>C</WorkcodeType>
<WorkcodeEstimateCheck>Y</WorkcodeEstimateCheck>
</WorkcodeDetail>
<WorkcodeDetail>
<WorkcodeCategory>1</WorkcodeCategory>
<Workcode>T9</Workcode>
<WorkcodeName>T3 Overtime Pr.</WorkcodeName>
<WorkcodeCommissionRate>150000</WorkcodeCommissionRate>
<WorkcodeFlags>NNNNNNNN</WorkcodeFlags>
<ExtraWorkcodeName>T3 Overtime Pr.</ExtraWorkcodeName>
<WorkcodeType>T</WorkcodeType>
<WorkcodeEstimateCheck>Y</WorkcodeEstimateCheck>
</WorkcodeDetail>
</CategoryDetail>
try isRemoveLineWhenBlank="true" set to false in your textFields