One excel Sheet for each subreport (No groups in the main report)jaspersoft iReport - jasper-reports

This is really driving me mad.. I read everywhere but still can't understand why mine isn't working
I have a main report( a dummy query returning me only one row) and 2 subreports(each with its own header) found in two different detail band. The second subreport splits into multiple excel sheets!
The main report doesn't contain any groups.. its just a dummy query and has no links with the subreports.
This is what i did in the main report:
Add in Properties : Name="net.sf.jasperreports.export.xls.one.page.per.sheet " with Value="True"
Set Ignore Pagination="True"
Added a Line element and set the Properties Expression: Name="net.sf.jasperreports.export.xls.break.after.row" and Default Value="True"
Then for the second subreport:
Set Ignore Pagination="True"
I just want one excel sheet for each subreports. But the second subreport is being split to multiple sheets... :(
Does anybody know what's the problem...?
I also read an issue with ignore pagination and page breaks here:
http://community.jaspersoft.com/ireport-designer/issues/2575
I am using the Jaspersoft iReport Designer 5.0.1
======================================
My jrxml for the main report:
<?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="Sample_Report28022013" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true" uuid="1808a381-4204-4662-9cc0-7d154bcc0890">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="ireport.jasperserver.reportUnit" value="/reports/Test/Subreports"/>
<property name="ireport.jasperserver.url" value="http://192.168.17.114:8080/jasperserver/services/repository"/>
<property name="net.sf.jasperreports.export.xls.one.page.per.sheet" value="True"/>
<property name="net.sf.jasperreports.export.html.remove.emtpy.space.between.rows" value="True"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\Documents and Settings\\TreshmaC\\Desktop\\WCHY\\JasperSoft\\"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT
tableliste."ident" AS tableliste_ident
FROM
"public"."tableliste" tableliste
LIMIT 1]]>
</queryString>
<field name="tableliste_ident" class="java.lang.Integer"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="7" splitType="Stretch"/>
</title>
<pageHeader>
<band height="5" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="7" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="97" splitType="Stretch">
<subreport>
<reportElement uuid="ea3a0ff6-f82f-43c0-8c7b-3d06e699f2f0" x="0" y="0" width="555" height="75"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["repo:Sample_Report28022013_subreport1.jrxml"]]></subreportExpression>
</subreport>
<break>
<reportElement uuid="3568174b-2ea9-4973-8e12-adcb7f54685a" x="0" y="83" width="100" height="1"/>
</break>
</band>
<band height="94" splitType="Prevent">
<subreport>
<reportElement uuid="b6ab1daa-122a-4a4b-8f60-f9fe2ba78204" x="0" y="13" width="555" height="72">
<property name="net.sf.jasperreports.export.xls.break.before.row" value="True"/>
</reportElement>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["repo:Sample_Report28022013_subreport2.jrxml"]]></subreportExpression>
</subreport>
</band>
</detail>
<columnFooter>
<band height="7" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="7" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="203" splitType="Stretch">
<componentElement>
<reportElement uuid="2651da09-f5ff-45de-91cb-6d9f0a8af724" x="0" y="0" width="555" height="200"/>
<mp:map xmlns:mp="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<mp:latitudeExpression><![CDATA[37.7750f]]></mp:latitudeExpression>
<mp:longitudeExpression><![CDATA[-122.4183f]]></mp:longitudeExpression>
</mp:map>
</componentElement>
</band>
</summary>
</jasperReport>
==================================================
jrxml file for the second subreport:
<?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="Sample_Report28022013_subreport2" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isIgnorePagination="true" uuid="5a86bc51-7425-4897-b74c-0dcf7016c666">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="ireport.jasperserver.reportUnit" value="/reports/Test/Subreports"/>
<property name="ireport.jasperserver.url" value="http://192.168.17.114:8080/jasperserver/services/repository"/>
<property name="net.sf.jasperreports.export.html.remove.emtpy.space.between.rows" value="True"/>
<queryString>
<![CDATA[SELECT
ad_dcr."id_client" AS ad_dcr_id_client,
ad_dcr."detail_obj_dem" AS ad_dcr_detail_obj_dem,
ad_dcr."cre_mnt_octr" AS ad_dcr_cre_mnt_octr,
ad_dcr."cre_mnt_deb" AS ad_dcr_cre_mnt_deb,
ad_cli."id_client" AS ad_cli_id_client,
ad_cli."num_port" AS ad_cli_num_port,
ad_cli."pp_prenom" AS ad_cli_pp_prenom,
ad_cli."pays" AS ad_cli_pays,
ad_cli."email" AS ad_cli_email,
ad_cli."pp_nom" AS ad_cli_pp_nom
FROM
"public"."ad_cli" ad_cli LEFT JOIN "public"."ad_dcr" ad_dcr ON ad_cli."id_client" = ad_dcr."id_client"
ORDER BY ad_cli."id_client"]]>
</queryString>
<field name="ad_dcr_id_client" class="java.lang.Integer"/>
<field name="ad_dcr_detail_obj_dem" class="java.lang.String"/>
<field name="ad_dcr_cre_mnt_octr" class="java.math.BigDecimal"/>
<field name="ad_dcr_cre_mnt_deb" class="java.math.BigDecimal"/>
<field name="ad_cli_id_client" class="java.lang.Integer"/>
<field name="ad_cli_num_port" class="java.lang.String"/>
<field name="ad_cli_pp_prenom" class="java.lang.String"/>
<field name="ad_cli_pays" class="java.lang.Integer"/>
<field name="ad_cli_email" class="java.lang.String"/>
<field name="ad_cli_pp_nom" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="23" splitType="Stretch"/>
</title>
<pageHeader>
<band height="43" splitType="Stretch">
<staticText>
<reportElement uuid="a071e7c5-1a11-497b-9eee-6b243a947965" x="378" y="0" width="177" height="39"/>
<textElement textAlignment="Right">
<font fontName="Castellar" size="26"/>
</textElement>
<text><![CDATA[DCR ]]></text>
</staticText>
</band>
</pageHeader>
<columnHeader>
<band height="22" splitType="Stretch">
<frame>
<reportElement uuid="12e8ca58-2196-4a8a-9137-c5104e63a485" mode="Opaque" x="0" y="0" width="555" height="20" backcolor="#006666"/>
</frame>
<staticText>
<reportElement uuid="a1b68cab-e347-4a8f-87f8-01064a78854f" x="12" y="0" width="100" height="20" forecolor="#FFFFFF"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Client ID]]></text>
</staticText>
<staticText>
<reportElement uuid="8a1870d5-2682-45a1-bf8b-31a613028daf" x="312" y="0" width="143" height="20" forecolor="#FFFFFF"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Achat]]></text>
</staticText>
<staticText>
<reportElement uuid="df37206c-95bf-4d03-8add-3fc7ca1d07a9" x="455" y="0" width="100" height="20" forecolor="#FFFFFF"/>
<textElement textAlignment="Center">
<font isBold="true"/>
</textElement>
<text><![CDATA[Montant]]></text>
</staticText>
<staticText>
<reportElement uuid="40e2dded-de55-4692-8e8d-2e94127dd28e" x="112" y="0" width="100" height="20" forecolor="#FFFFFF"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Nom]]></text>
</staticText>
<staticText>
<reportElement uuid="45abf217-95a0-4ef4-963b-45c2915e5723" x="212" y="0" width="100" height="20" forecolor="#FFFFFF"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Pays]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="26" splitType="Stretch">
<textField>
<reportElement uuid="7f43f0d2-fcc2-45b3-865e-02d643954c1c" x="12" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{ad_dcr_id_client}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="c14584b6-c516-423a-ac17-bc4ffeb7d74c" x="312" y="0" width="143" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{ad_dcr_detail_obj_dem}]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00">
<reportElement uuid="88cb8587-2e82-4ea6-9c1d-f53767ffb93c" x="455" y="0" width="100" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{ad_dcr_cre_mnt_deb}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="f4feb876-fbb5-4b7b-b9fb-f24528dfb762" x="112" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{ad_cli_pp_nom}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="5fed5609-a23b-4cbe-a4b2-a0ebf36e3cd5" x="212" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{ad_cli_pays}]]></textFieldExpression>
</textField>
<line>
<reportElement uuid="6eb43b44-1a3f-4b05-be37-4caeb35e5feb" x="0" y="20" width="555" height="1"/>
</line>
</band>
</detail>
<columnFooter>
<band height="7" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="8" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="7" splitType="Stretch"/>
</summary>
</jasperReport>

I think You can just set the size of a page in main and sub reports to some very large value, for example 999999 and insert "page break" from pallete between sub-reports.
This way You should get each subreport in different page, but second one should not span across multiple pages.

You don´t need to do anthing in the Main. It´s all in the subreports. For example the main:
<detail>
<band height="397">
<subreport>
<reportElement positionType="Float" x="0" y="298" width="801" height="99" uuid="61789fb8-f34c-46d4-a13e-6cfeba5567a7">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["repo:"]]></subreportExpression>
</subreport>
<subreport>
<reportElement positionType="Float" x="0" y="298" width="801" height="99" uuid="61789fb8-f34c-46d4-a13e-6cfeba5567a7">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["repo:"]]></subreportExpression>
</subreport>
</band>
</detail>
And use in the last element you have (like a textfield) a BreakAfter:
<textField isBlankWhenNull="true">
<reportElement x="280" y="0" width="120" height="30" uuid="632a6ed9-70ce-4ecd-a3e0-aaec6af95aa9">
<property name="net.sf.jasperreports.export.xls.break.after.row" value="true"/>
<property name="net.sf.jasperreports.export.xls.sheet.name" value="Nombre y apellidos"/>
</reportElement>
<box>
<topPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["TOTAL"]]></textFieldExpression>
</textField>
This sould be placed at the end of your report

Related

Too much white space around jasper subreport

There is too much white space produced before and after a subreport in a pdf file generated using jasper.
Any help to eliminate the space around subreport component will help a lot.
Here is the main report template
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.12.2.final using JasperReports Library version 6.12.2-75c5e90a222ab406e416cbf590a5397028a52de3 -->
<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="with_sub_report" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="256c6d62-ba9b-404c-8e1c-eaeeca988125">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="JOURNAL_WITH_PAYMENT"/>
<property name="net.sf.jasperreports.data.adapter" value="JOURNAL_WITH_PAYMENT.xml"/>
<queryString language="json">
<![CDATA[entries]]>
</queryString>
<field name="jouranl_date" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="jouranl_date"/>
<fieldDescription><![CDATA[jouranl_date]]></fieldDescription>
</field>
<field name="journal_ref" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="journal_ref"/>
<fieldDescription><![CDATA[journal_ref]]></fieldDescription>
</field>
<field name="journal_line" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="journal_line"/>
<fieldDescription><![CDATA[journal_line]]></fieldDescription>
</field>
<field name="amount" class="java.math.BigDecimal">
<property name="net.sf.jasperreports.json.field.expression" value="amount"/>
<fieldDescription><![CDATA[amount]]></fieldDescription>
</field>
<field name="crncy" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="crncy"/>
<fieldDescription><![CDATA[crncy]]></fieldDescription>
</field>
<field name="dr_or_cr" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="dr_or_cr"/>
<fieldDescription><![CDATA[dr_or_cr]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="34" splitType="Stretch">
<staticText>
<reportElement x="0" y="5" width="100" height="25" uuid="0d465cec-66da-4e16-829e-c8728f0b770e"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Journal Date]]></text>
</staticText>
<staticText>
<reportElement x="150" y="5" width="100" height="25" uuid="c4dac4a0-f457-4700-b7ac-1d3b31604f62"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Journal Ref Num]]></text>
</staticText>
<staticText>
<reportElement x="290" y="5" width="100" height="25" uuid="81c750c7-2df3-4200-89e7-b8535b3193a5"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Journal line]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="25" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<textField>
<reportElement x="-10" y="4" width="120" height="16" uuid="f5f87f9d-fc7d-44ae-8c13-63b49db240ec">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="2e697f8a-57a8-4d0e-8faa-47180c6b44ae"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{jouranl_date}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="4" width="100" height="16" uuid="cf85e544-bef5-4e5b-9e73-7704a2bd4c5a">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="6c255841-3412-410f-a976-b3ec67868bc3"/>
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{journal_ref}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="290" y="4" width="100" height="16" uuid="2b8664a2-652e-4426-9f8d-746286f7a12e">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="1f3fb198-93d5-4592-b33e-4a61a1a9513b"/>
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{journal_line}]]></textFieldExpression>
</textField>
<subreport overflowType="Stretch">
<reportElement x="-18" y="13" width="30" height="7" uuid="64cc178b-58b5-4273-ad0d-ea75d2c2524e">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<printWhenExpression><![CDATA[new String("C").equals(($F{dr_or_cr}))]]></printWhenExpression>
</reportElement>
<subreportParameter name="dr_or_cr">
<subreportParameterExpression><![CDATA[$F{dr_or_cr}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="crncy">
<subreportParameterExpression><![CDATA[$F{crncy}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="amount">
<subreportParameterExpression><![CDATA[$F{amount}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
<subreportExpression><![CDATA["payment_sub_report.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<pageFooter>
<band splitType="Stretch"/>
</pageFooter>
<summary>
<band height="52" splitType="Prevent">
<staticText>
<reportElement x="232" y="22" width="100" height="30" uuid="3fcd32ad-45a6-4153-9d0e-2a7c9f9f44d8"/>
<text><![CDATA[Static Text]]></text>
</staticText>
</band>
</summary>
</jasperReport>
And here is the subreport
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.12.2.final using JasperReports Library version 6.12.2-75c5e90a222ab406e416cbf590a5397028a52de3 -->
<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="payment_sub_report" pageWidth="549" pageHeight="30" columnWidth="549" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="aa23536f-b74a-40f9-911a-b1cbfad0a6a3">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="dr_or_cr" class="java.lang.String"/>
<parameter name="crncy" class="java.lang.String"/>
<parameter name="amount" class="java.math.BigDecimal"/>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="29" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<textField>
<reportElement x="-12" y="4" width="100" height="16" uuid="ca02c58c-8c11-4354-9ebb-76a807062e46"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$P{dr_or_cr}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="183" y="4" width="100" height="16" uuid="763524dc-97d5-4e40-9dee-ad53d2d11be2"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$P{crncy}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="385" y="4" width="100" height="16" uuid="06f2e836-3420-4dff-b512-4ba837b0d1c6"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$P{amount}]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
Moreover the subreport comes too much to the right inspite of placing it to the exteme left in the main report
The output is uploaded here in this link
https://drive.google.com/file/d/117lFxIBE34gVdl7WkaG9Y_G_3f-Vx79l/view?usp=sharing

Gap between detail and column footer bands even after setting "Float Column Footer" to true

I am creating a jasper report showing some person names. I need to show the number of persons in the list at the bottom.
The problem I am facing is I am getting a small gap between persons list and the label "Total Candidates".
For the reference, please check below image:
In the beginning, column footer was getting shown at the end of page, leaving a lot of gap. Then I found few good StackOverflow links:
1) Issue with Column footer and Summary bands
2) Jasper Reports - how to get column footer to appear directly below details band
which suggested to set "Float Column Footer" to true. After doing that, the gap reduced and my column footer is almost below the detail band. But still, as shown in the picture, there is some gap remaining, which I don't know how to remove.
Edit: Here is my jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isFloatColumnFooter="true" uuid="b7718df8-d1d7-46e7-9a66-7d3fe24c720c">
<parameter name="ReportName" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="firstName" class="java.lang.String">
<fieldDescription><![CDATA[firstName]]></fieldDescription>
</field>
<field name="id" class="java.lang.String">
<fieldDescription><![CDATA[id]]></fieldDescription>
</field>
<field name="lastName" class="java.lang.String">
<fieldDescription><![CDATA[lastName]]></fieldDescription>
</field>
<field name="middleName" class="java.lang.String">
<fieldDescription><![CDATA[middleName]]></fieldDescription>
</field>
<title>
<band height="42" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="555" height="42" uuid="b6eaae95-75f5-4b33-978b-8afd7f9ecfee"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="20"/>
</textElement>
<textFieldExpression><![CDATA[$P{ReportName}]]></textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
<band height="20" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="32" height="20" uuid="3dfe1b88-b77c-465e-bc1d-d96223c69692"/>
<text><![CDATA[Sr. No.]]></text>
</staticText>
<staticText>
<reportElement x="32" y="0" width="188" height="20" uuid="96add808-7f90-405d-93fc-ae64596df9e3"/>
<textElement textAlignment="Center"/>
<text><![CDATA[First Name]]></text>
</staticText>
<staticText>
<reportElement x="220" y="0" width="188" height="20" uuid="dd5aa422-a23c-4a4c-a464-9e927503c342"/>
<textElement textAlignment="Center"/>
<text><![CDATA[Middle Name]]></text>
</staticText>
<staticText>
<reportElement x="408" y="0" width="147" height="20" uuid="e7894574-4f95-4a04-b54b-16f636dc453c"/>
<textElement textAlignment="Center"/>
<text><![CDATA[Last Name]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="32" height="20" uuid="b0a9a50f-f275-4802-ba80-04559e57c75e"/>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="32" y="0" width="188" height="20" uuid="4ea4f73b-06bb-4553-848b-eecdc6be51b2"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{firstName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="220" y="0" width="188" height="20" uuid="d2ea4610-7ee7-4921-babe-6d9040592843"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{middleName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="408" y="0" width="147" height="20" uuid="045272ac-1387-49c6-a4e1-237725e08269"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{lastName}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="20" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="79" height="20" uuid="5a71d074-89c3-4b70-ae90-840cb37b45e8"/>
<text><![CDATA[Total Candidates:]]></text>
</staticText>
</band>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
Any suggestions would be really appreciated!
<summary>
<band height="0" splitType="Stretch"/>
</summary>
or remove the tag completely.

jasper report display odd or even pages sequentially

How can i display jasper report page like ODD: 1,3,5,7,9 ..... and EVEN :2,4,6,8,10,12......?
I tried to set print when expression in jasper. I used $V{PAGE_NUMBER} % 2 == 1, but it just break the page 1 or 2.
How to print details in separate odd and even sequences?
I have tried this code:
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="null" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="927727f4-bbc3-4b13-bde4-00e4c9eff6b1">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString language="SQL">
<![CDATA[Select * from area1;]]>
</queryString>
<field name="AREA_NAME" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement x="304" y="14" width="100" height="20" uuid="4260d472-d804-440a-9af6-1c3298d2f58f"/>
<textElement>
<font size="13" isBold="true" isUnderline="true" isStrikeThrough="false"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="35">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER} % 2 == 1]]></printWhenExpression>
</band>
</pageHeader>
<columnHeader>
<band height="40" splitType="Stretch">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER} % 2 == 1]]></printWhenExpression>
<staticText>
<reportElement x="23" y="2" width="100" height="20" uuid="5e8b28a3-3518-46e4-a62f-dfa585fc0c1b"/>
<text><![CDATA[AREA_NAME]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="136" splitType="Stretch">
<printWhenExpression><![CDATA[$P{REPORT_PAGE}%2 == 0]]></printWhenExpression>
<textField>
<reportElement x="23" y="0" width="100" height="20" uuid="4b25e363-9dc8-47d4-8af4-3e6919e06020"/>
<textFieldExpression><![CDATA[$F{AREA_NAME}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch">
<printWhenExpression><![CDATA[Boolean.valueOf( $V{PAGE_NUMBER}.intValue() % 2 == 1 )]]></printWhenExpression>
<textField>
<reportElement x="367" y="17" width="80" height="20" uuid="00d0dc34-6c9f-4265-83c8-b6778d349551"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="459" y="17" width="40" height="20" uuid="fb935dbc-39fb-4589-b6fa-0af65a3c41b9"/>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>

Subreport using XML file datasource don't work

I'm having a problem with subreport connected to a XML file. When I execute the report the preview don't show the subreport data, but if I execute the subreport alone, it shows the data correctly. What am I doing wrong?
Data File:
<REPORTDATA>
<HEAD>
<NUMBER>1</NUMBER>
<DESC>BLA BLA</DESC>
<DATE>2012.01.01</DATE>
</HEAD>
<GRID1>
<line id="1">
<NUMBER>11</NUMBER>
<DESC>g11BLA BLA</DESC>
<DATE>2012.01.01</DATE>
</line>
<line id="2">
<NUMBER>12</NUMBER>
<DESC>g12BLA BLA</DESC>
<DATE>2012.01.01</DATE>
</line>
</GRID1>
<GRID2>
<line id="1">
<NUMBER>21</NUMBER>
<DESC>g21BLA BLA</DESC>
<DATE>2012.01.01</DATE>
</line>
<line id="2">
<NUMBER>22</NUMBER>
<DESC>g22BLA BLA</DESC>
<DATE>2012.01.01</DATE>
</line>
</GRID2>
Report:
<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="reporttest" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6a9eed56-d1c3-46d8-9e16-4166c146b8a3">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\Users\\A2O\\Desktop\\"]]></defaultValueExpression>
</parameter>
<queryString language="xPath">
<![CDATA[/REPORTDATA/HEAD]]>
</queryString>
<field name="NUMBER" class="java.lang.String">
<fieldDescription><![CDATA[NUMBER]]></fieldDescription>
</field>
<field name="DESC" class="java.lang.String">
<fieldDescription><![CDATA[DESC]]></fieldDescription>
</field>
<field name="DATE" class="java.lang.String">
<fieldDescription><![CDATA[DATE]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<textField>
<reportElement uuid="bd7929b3-092d-44b9-b488-c0418fb57749" x="4" y="6" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="de902808-67e8-4b08-bd0b-c1d735409843" x="6" y="32" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{DESC}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="86d57bd0-01d3-4b1f-b9bb-0eb7cf2c19fc" x="5" y="56" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{DATE}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="13" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="12" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="26" splitType="Stretch">
<staticText>
<reportElement uuid="819f4027-8ad0-46b4-b07c-c80234fe8411" x="12" y="0" width="100" height="20"/>
<textElement/>
<text><![CDATA[Static text]]></text>
</staticText>
</band>
</detail>
<columnFooter>
<band height="11" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="9" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch">
<subreport>
<reportElement uuid="4ab29d23-9ead-491e-8ca3-8f9790280026" x="0" y="0" width="555" height="42"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "reporttest_subreport1.jasper"]]></subreportExpression>
</subreport>
</band>
</summary>
Subreport:
<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="reporttest_subreport1" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="ca109af7-4e08-405d-b43f-4062115c500e">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString language="xPath">
<![CDATA[/REPORTDATA/GRID1/line]]>
</queryString>
<field name="NUMBER" class="java.lang.String">
<fieldDescription><![CDATA[NUMBER]]></fieldDescription>
</field>
<field name="DESC" class="java.lang.String">
<fieldDescription><![CDATA[DESC]]></fieldDescription>
</field>
<field name="DATE" class="java.lang.String">
<fieldDescription><![CDATA[DATE]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band splitType="Stretch"/>
</title>
<pageHeader>
<band height="36" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="69" splitType="Stretch">
<staticText>
<reportElement uuid="867a24dd-6172-40ef-be33-f8e51fa21207" x="0" y="0" width="100" height="20"/>
<textElement/>
<text><![CDATA[Grid1 data:]]></text>
</staticText>
<staticText>
<reportElement uuid="0885dada-a149-4cb7-b82c-fdfa9847061d" x="32" y="49" width="100" height="20"/>
<textElement/>
<text><![CDATA[NUMBER]]></text>
</staticText>
<staticText>
<reportElement uuid="7261c001-6771-47dc-9749-5e6f64fb86df" x="159" y="49" width="100" height="20"/>
<textElement/>
<text><![CDATA[DESC]]></text>
</staticText>
<staticText>
<reportElement uuid="2b95c6fc-3fd9-4df1-89c6-5249173db3e1" x="287" y="49" width="100" height="20"/>
<textElement/>
<text><![CDATA[DATE]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="23" splitType="Stretch">
<textField>
<reportElement uuid="becea2ba-40fd-4208-8191-c7475293ed5b" x="32" y="1" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="182efb3b-6a66-4634-be35-fe03e8a0cd45" x="159" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{DESC}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="bdb70a35-b4e6-4857-96c5-f607ee59bc07" x="287" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{DATE}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="15" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="6" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="7" splitType="Stretch"/>
</summary>
For sub report with the xml files as a datasource, you need to specify the datasource for the sub report.
Properties you need to have a look at are
Connection Type : Use a Datasource Expression
Connection / Datasource Expression :
((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//YOUR_SUBREPORT_ENTITY").
You will need something similar to this
<dataSourceExpression><![CDATA[
((net.sf.jasperreports.engine.data.JRXmlDataSource)
$P{REPORT_DATA_SOURCE}).subDataSource("//YOUR_SUBREPORT_ENTITY") ]]>
</dataSourceExpression>
Maybe now its not actually for you, but someone it help.
All what need - its set datasource expression for subreport, how it realise:
<dataSourceExpression>
<![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).datasource("YOUR_SUBREPORT_XPATH") ]]>
</dataSourceExpression>
Instead "YOUR_SUBREPORT_XPATH" use XPath that you set in subreport. In this case it will be "/REPORTDATA/GRID1/line"
In newer versions of Jasper (i used 6.x) is better and correct use .datasource(...) instead .subDataSource(...)

Blank subreport in Jasper report

I have seen quite a few questions on blank subreports but none of them provide the information I need. I have a master report:
<?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="sample_report" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="reportTitle" class="java.lang.String"/>
<parameter name="reportSubTitle" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="65" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="555" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$P{reportTitle}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="434" y="40" width="80" height="20"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="514" y="40" width="40" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="20" width="555" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$P{reportSubTitle}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band height="109" splitType="Stretch">
<subreport isUsingCache="false">
<reportElement x="0" y="0" width="555" height="100" isPrintWhenDetailOverflows="true"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["sample_report_activity_report.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band splitType="Stretch"/>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>
And a subreport:
<?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="sample_report_activity_report" pageWidth="802" pageHeight="555" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="802" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString language="SQL">
<![CDATA[SELECT ActivityType, Count, Amount, ActivityDate FROM Activity WHERE ARIID = 1]]>
</queryString>
<field name="ActivityType" class="java.lang.String"/>
<field name="Count" class="java.lang.String"/>
<field name="Amount" class="java.lang.String"/>
<field name="ActivityDate" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="24" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="802" height="20"/>
<textElement textAlignment="Center"/>
<text><![CDATA[Activity Report]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="25" splitType="Stretch">
<staticText>
<reportElement x="12" y="0" width="100" height="20"/>
<textElement/>
<text><![CDATA[ActivityType]]></text>
</staticText>
<staticText>
<reportElement x="112" y="0" width="100" height="20"/>
<textElement/>
<text><![CDATA[Count]]></text>
</staticText>
<staticText>
<reportElement x="215" y="0" width="100" height="20"/>
<textElement/>
<text><![CDATA[Amount]]></text>
</staticText>
<staticText>
<reportElement x="315" y="0" width="100" height="20"/>
<textElement/>
<text><![CDATA[ActivityDate]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="22" splitType="Stretch">
<textField>
<reportElement x="12" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{ActivityType}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="115" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{Count}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="215" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{Amount}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="315" y="2" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{ActivityDate}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="802" height="20"/>
<textElement textAlignment="Center"/>
<text><![CDATA[--- End of Activity Report ---]]></text>
</staticText>
</band>
</summary>
</jasperReport>
And I have the following Java code:
Map parameters = new HashMap();
parameters.put("reportTitle", "Report");
parameters.put("reportSubTitle", "Activity Date 10/25/2011");
JasperReport jasperReportMain = JasperCompileManager.compileReport("c:\\tempfilepath\\sample_report.jrxml");
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReportMain, parameters, con);
JasperExportManager.exportReportToPdfFile(jasperPrint, "c:\\tempfilepath\\SampleReport.pdf");
As far as I can tell I have followed all the previous advice given and I still don't have any data showing up in my subreport when I run the main report. What am I doing wrong?
May be the query in your subreport doesn't return any row. You might try adding No Data band in your subreport, put some Static Text in it, and set the (sub) report property When No Data to No Data Section.
I didn't notice any irregularities from your XML JR code.
First, are you sure your Data Source (database resultset) is returning any results and is set up properly?
I would also recommend installing the IREPORT Designer tool for Jasper Reports. I think the latest version is 4.1.2. This will help you tremendously in both designing and error/exception handling.
I might be wrong because I don't understand much jrxml as a code as I have always developed reports using iReport. Are u passing parameters from main report to subreport? If yes,just check ,by right-click on subreport that whether you have passed the parameters for your subreports.