How to migrate if-else expression from JasperReports 4.x to JasperReports 2.x? - jasper-reports

How to migrate if-else expression from JasperReports 4.x syntax to JasperReports 2.x syntax?
This is my code:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
name="convertString"
columnCount="1"
printOrder="Vertical"
orientation="Portrait"
pageWidth="595"
pageHeight="842"
columnWidth="555"
columnSpacing="0"
leftMargin="20"
rightMargin="20"
topMargin="20"
bottomMargin="20"
whenNoDataType="NoPages"
isTitleNewPage="false"
isSummaryNewPage="false">
<property name="ireport.zoom" value="1.0" />
<property name="ireport.x" value="0" />
<property name="ireport.y" value="6" />
<property name="ireport.scriptlethandling" value="0" />
<property name="ireport.encoding" value="UTF-8" />
<import value="java.util.*" />
<import value="net.sf.jasperreports.engine.*" />
<import value="net.sf.jasperreports.engine.data.*" />
<import value="com.google.common.base.*" />
<parameter name="pd_id" isForPrompting="true" class="java.lang.Integer"/>
<parameter name="acl" isForPrompting="true" class="java.lang.String"/>
<queryString><![CDATA[select * from WF_PROC_DEF,acl_module
where pd_id=$P{pd_id}
and acl_module_id = $P{acl}]]></queryString>
<field name="PD_ID" class="java.math.BigDecimal"/>
<field name="PD_NAME" class="java.lang.String"/>
<field name="OLD_PD_ID" class="java.lang.String"/>
<field name="ACL_MODULE_ID" class="java.lang.String"/>
<field name="ACL_MODULE_DESC" class="java.lang.String"/>
<background>
<band height="0" isSplitAllowed="true" >
</band>
</background>
<title>
<band height="79" isSplitAllowed="true" >
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
x="17"
y="18"
width="100"
height="20"
key="textField"
isRemoveLineWhenBlank="true"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement>
<font/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{pd_id}==1 ? "External Agencies" :
$P{pd_id}==2 ? "Planning, Building & Land" :
$P{pd_id}==3 ? "Composit Forms" :$P{pd_id}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="0" isSplitAllowed="true" >
</band>
</pageHeader>
<columnHeader>
<band height="20" isSplitAllowed="true" >
<staticText>
<reportElement
x="0"
y="0"
width="277"
height="20"
key="staticText"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement>
<font/>
</textElement>
<text><![CDATA[PD_ID]]></text>
</staticText>
<staticText>
<reportElement
x="277"
y="0"
width="277"
height="20"
key="staticText"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement>
<font/>
</textElement>
<text><![CDATA[PD_NAME]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" isSplitAllowed="true" >
<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
x="0"
y="0"
width="277"
height="20"
key="textField"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement>
<font/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{PD_ID}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
x="277"
y="0"
width="277"
height="20"
key="textField"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement>
<font/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{PD_NAME}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" isSplitAllowed="true" >
</band>
</columnFooter>
<pageFooter>
<band height="54" isSplitAllowed="true" >
</band>
</pageFooter>
<summary>
<band height="42" isSplitAllowed="true" >
</band>
</summary>
</jasperReport>
Another question:
Do you have a few brief examples or tutorials on iReport 2.0.2?

I don't think the if else format has changed. You can use the ternary operator to accomplish your goal. Please show error output if you're getting specific problems.

Related

iReport: How to store a particular value from a field based on a condition

I have a jasper report(ireport 1.2.0) which is a vo report where the sql query is not inside the jasper but comes directly from the java code of the application. Only the fields ( which are called vo fields ) are mentioned in the jasper report. I have to use ireport 1.2.0 for this.
This jasper has a number of sub jaspers,one of which I have to modify. This .The partial output of the report is as shown here: https://ibb.co/gVSKQyR
Below is the jrxml file of the sub jasper:
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
name="BillSummaryPage"
columnCount="1"
printOrder="Vertical"
orientation="Portrait"
pageWidth="595"
pageHeight="842"
columnWidth="535"
columnSpacing="0"
leftMargin="0"
rightMargin="16"
topMargin="2"
bottomMargin="2"
whenNoDataType="NoPages"
isTitleNewPage="false"
isSummaryNewPage="false">
<property name="ireport.scriptlethandling" value="0" />
<property name="ireport.encoding" value="UTF-8" />
<import value="java.util.*" />
<import value="net.sf.jasperreports.engine.*" />
<import value="net.sf.jasperreports.engine.data.*" />
<parameter name="imagePath" isForPrompting="true" class="java.lang.String"/>
<parameter name="status" isForPrompting="true" class="java.lang.Integer"/>
<parameter name="billNumber" isForPrompting="true" class="java.lang.String"/>
<parameter name="mrdNumber" isForPrompting="true" class="java.lang.String"/>
<parameter name="confirmedDate" isForPrompting="true" class="java.util.Date"/>
<parameter name="patientName" isForPrompting="true" class="java.lang.String"/>
<parameter name="visitNumber" isForPrompting="true" class="java.lang.String"/>
<parameter name="admitDate" isForPrompting="true" class="java.util.Date"/>
<field name="description" class="java.lang.String"/>
<field name="processedDate" class="java.util.Date"/>
<field name="rate" class="java.lang.Double"/>
<field name="qty" class="java.lang.Double"/>
<field name="internalDiscount" class="java.lang.Double"/>
<field name="debitAmount" class="java.lang.Double"/>
<field name="creditAmount" class="java.lang.Double"/>
<field name="categoryForReport" class="java.lang.String"/>
<field name="amount" class="java.lang.Double"/>
<field name="packageOrderName" class="java.lang.String"/>
<field name="totalItemDiscount" class="java.lang.Double"/>
<field name="pageGroup" class="java.lang.String"/>
<field name="totAmountToPrint" class="java.lang.Double"/>
<field name="billPackageYesNo" class="java.lang.Boolean"/>
<field name="doctorCode" class="java.lang.String"/>
<field name="groupDescription" class="java.lang.String"/>
<field name="additionalDiscount" class="java.lang.Double"/>
<variable name="reporttotamount" class="java.lang.Double" resetType="Report" calculation="Sum">
<variableExpression><![CDATA[$F{amount}]]></variableExpression>
</variable>
<variable name="reporttotcredit" class="java.lang.Double" resetType="Report" calculation="Sum">
<variableExpression><![CDATA[$F{creditAmount}]]></variableExpression>
</variable>
<variable name="reporttotdebit" class="java.lang.Double" resetType="Report" calculation="Sum">
<variableExpression><![CDATA[$F{debitAmount}]]></variableExpression>
</variable>
<variable name="reporttotdiscount" class="java.lang.Double" resetType="Report" calculation="Sum">
<variableExpression><![CDATA[$F{totalItemDiscount}]]></variableExpression>
</variable>
<variable name="groupPageNo" class="java.lang.Integer" resetType="Report" calculation="Nothing">
<variableExpression><![CDATA[$V{PAGE_NUMBER}]]></variableExpression>
</variable>
<variable name="Vqty" class="java.lang.Double" resetType="Group" resetGroup="category" calculation="Sum">
<variableExpression><![CDATA[$F{qty}]]></variableExpression>
<initialValueExpression><![CDATA[new Double(0)]]></initialValueExpression>
</variable>
<variable name="Vamount" class="java.lang.Double" resetType="Group" resetGroup="category" calculation="Sum">
<variableExpression><![CDATA[$F{amount}]]></variableExpression>
<initialValueExpression><![CDATA[new Double(0)]]></initialValueExpression>
</variable>
<variable name="VtotalItemDiscount" class="java.lang.Double" resetType="Group" resetGroup="category" calculation="Sum">
<variableExpression><![CDATA[$F{totalItemDiscount}]]></variableExpression>
</variable>
<variable name="VdebitAmount" class="java.lang.Double" resetType="Group" resetGroup="category" calculation="Sum">
<variableExpression><![CDATA[$F{debitAmount}]]></variableExpression>
<initialValueExpression><![CDATA[new Double(0)]]></initialValueExpression>
</variable>
<variable name="VcreditAmount" class="java.lang.Double" resetType="Group" resetGroup="category" calculation="Sum">
<variableExpression><![CDATA[$F{creditAmount}]]></variableExpression>
</variable>
<variable name="groupTotAmountToPrint" class="java.lang.Double" resetType="Group" resetGroup="category" calculation="Sum">
<variableExpression><![CDATA[new Double( ($F{totAmountToPrint}.doubleValue())-($F{totalItemDiscount}.doubleValue()))]]></variableExpression>
</variable>
<variable name="totAdditionalDiscount" class="java.lang.Double" resetType="Group" resetGroup="category" calculation="Sum">
<variableExpression><![CDATA[$F{additionalDiscount}]]></variableExpression>
</variable>
<variable name="bedcharge" class="java.lang.Double" resetType="Report" calculation="Nothing">
</variable>
<group name="category" minHeightToStartNewPage="20" >
<groupExpression><![CDATA[$F{categoryForReport}+$F{doctorCode}]]></groupExpression>
<groupHeader>
<band height="17" isSplitAllowed="true" >
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true" evaluationTime="Group" evaluationGroup="category" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
mode="Transparent"
x="144"
y="2"
width="303"
height="15"
forecolor="#000000"
backcolor="#FFFFFF"
key="textField"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="false"
isRemoveLineWhenBlank="true"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single">
<font fontName="Arial Black" pdfFontName="arial.ttf" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" />
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{groupDescription}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="0.00" isBlankWhenNull="false" evaluationTime="Group" evaluationGroup="category" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
mode="Transparent"
x="460"
y="1"
width="68"
height="15"
forecolor="#000000"
backcolor="#FFFFFF"
key="textField"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="true"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement textAlignment="Right" verticalAlignment="Bottom" rotation="None" lineSpacing="Single">
<font fontName="Arial Black" pdfFontName="arial.ttf" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" />
</textElement>
<textFieldExpression class="java.lang.Double"><![CDATA[new Double( ($V{groupTotAmountToPrint}.doubleValue())+$V{totAdditionalDiscount}.doubleValue())]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true" evaluationTime="Group" evaluationGroup="category" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
mode="Transparent"
x="4"
y="2"
width="136"
height="15"
forecolor="#000000"
backcolor="#FFFFFF"
key="textField-1"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="false"
isRemoveLineWhenBlank="true"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single">
<font fontName="Arial Black" pdfFontName="arial.ttf" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" />
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{doctorCode}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
<groupFooter>
<band height="0" isSplitAllowed="true" >
</band>
</groupFooter>
</group>
<background>
<band height="1" isSplitAllowed="true" >
</band>
</background>
<title>
<band height="1" isSplitAllowed="true" >
</band>
</title>
<pageHeader>
<band height="18" isSplitAllowed="true" >
<staticText>
<reportElement
mode="Transparent"
x="2"
y="2"
width="153"
height="15"
forecolor="#000000"
backcolor="#FFFFFF"
key="staticText-1"
stretchType="NoStretch"
positionType="Float"
isPrintRepeatedValues="false"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single">
<font fontName="Arial" pdfFontName="arial.ttf" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" />
</textElement>
<text><![CDATA[OUT OF PACKAGE DETAILS:-]]></text>
</staticText>
</band>
</pageHeader>
<columnHeader>
<band height="22" isSplitAllowed="true" >
<staticText>
<reportElement
mode="Transparent"
x="144"
y="4"
width="238"
height="16"
forecolor="#000000"
backcolor="#FFFFFF"
key="staticText"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single">
<font fontName="" pdfFontName="arialbd.ttf" size="10" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" />
</textElement>
<text><![CDATA[Particulars]]></text>
</staticText>
<staticText>
<reportElement
mode="Transparent"
x="481"
y="4"
width="48"
height="18"
forecolor="#000000"
backcolor="#FFFFFF"
key="staticText"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement textAlignment="Right" verticalAlignment="Top" rotation="None" lineSpacing="Single">
<font fontName="" pdfFontName="arialbd.ttf" size="10" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" />
</textElement>
<text><![CDATA[Charges]]></text>
</staticText>
<line direction="TopDown">
<reportElement
mode="Opaque"
x="0"
y="21"
width="530"
height="1"
forecolor="#000000"
backcolor="#FFFFFF"
key="line"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<graphicElement stretchType="NoStretch" pen="Thin" fill="Solid"
/>
</line>
<line direction="TopDown">
<reportElement
mode="Opaque"
x="0"
y="2"
width="530"
height="1"
forecolor="#000000"
backcolor="#FFFFFF"
key="line"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<graphicElement stretchType="NoStretch" pen="Thin" fill="Solid"
/>
</line>
<staticText>
<reportElement
mode="Transparent"
x="3"
y="4"
width="135"
height="16"
forecolor="#000000"
backcolor="#FFFFFF"
key="staticText-2"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single">
<font fontName="" pdfFontName="arialbd.ttf" size="10" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" />
</textElement>
<text><![CDATA[Doctor Code]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="0" isSplitAllowed="true" >
</band>
</detail>
<columnFooter>
<band height="4" isSplitAllowed="true" >
<line direction="TopDown">
<reportElement
mode="Opaque"
x="0"
y="3"
width="530"
height="1"
forecolor="#000000"
backcolor="#FFFFFF"
key="line-1"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<graphicElement stretchType="NoStretch" pen="Thin" fill="Solid"
/>
</line>
</band>
</columnFooter>
<pageFooter>
<band height="0" isSplitAllowed="true" >
</band>
</pageFooter>
<summary>
<band height="0" isSplitAllowed="true" >
</band>
</summary>
</jasperReport>
There are among others, 2 fields which are
Particulars - $F{groupDescription}
Charges - new Double( ($V{groupTotAmountToPrint}.doubleValue())+$V{totAdditionalDiscount}.doubleValue())
I want to create two variables which will store the two bed charges i.e 2600 (from row 2 ) and 20100 (from row 12) from the above jasper output. My difficulty is that there is no sql query and I have to manage this in the jasper itself. I am not able to get the expressions needed for the variables. Can this be done ? Any help would be greatly appreciated. Thank you.

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

Issue in genearting the sub report details?

I had created the report it is getting the values for first name and last name and invoice id but when I add the sub report the other values are not getting it is just printing the headings. Please solve my problem and suggest me.
It is printing as below image.
Main report code:
<?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="Usage Rport" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" >
<property name="com.jasperassistant.designer.GridHeight" value="12"/>
<property name="com.jasperassistant.designer.GridWidth" value="12"/>
<property name="com.jasperassistant.designer.SnapToGrid" value="false"/>
<property name="com.jasperassistant.designer.Grid" value="false"/>
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<import value="org.joda.time.DateTime"/>
<parameter name="invoice_id" class="java.lang.Integer"/>
<parameter name="entity_id" class="java.lang.Integer"/>
<parameter name="entityPhoneCountryCode" class="java.lang.String"/>
<parameter name="entityPhoneAreaCode" class="java.lang.String"/>
<parameter name="entityPhoneContry" class="java.lang.String"/>
<parameter name="invoiceDate" class="java.lang.String"/>
<parameter name="invoiceDueDate" class="java.lang.String"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["D:\\Ravi Workspace\\Openbrm\\open-brm-openbrm-2.0\\descriptors\\reports\\usage\\"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select co.first_name,co.last_name,b.id as user_id from swiss_cdr_event e join order_process o join base_user b on b.id=e.user_id and e.order_id = o.order_id join contact co on e.user_id=co.user_id where o.invoice_id=$P{invoice_id} and b.entity_id=$P{entity_id} order by e.call_start_date asc;]]>
</queryString>
<field name="first_name" class="java.lang.String"/>
<field name="last_name" class="java.lang.String"/>
<field name="user_id" class="java.lang.Integer"/>
<title>
<band height="20"/>
</title>
<pageHeader>
<band height="111">
<textField>
<reportElement x="5" y="13" width="200" height="15" />
<textElement>
<font size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{first_name}+" " +$F{last_name}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="185" y="13" width="140" height="15" />
<textElement textAlignment="Left">
<font isBold="true"/>
</textElement>
<text><![CDATA[Rechnungs-Nr. ]]></text>
</staticText>
<staticText>
<reportElement x="368" y="13" width="100" height="15" />
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Jahr / Monat]]></text>
</staticText>
<staticText>
<reportElement x="379" y="28" width="52" height="15" />
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[datiert]]></text>
</staticText>
<textField>
<reportElement x="252" y="13" width="100" height="15" />
<textElement>
<font isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.Integer"><![CDATA[$P{invoice_id}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="434" y="28" width="119" height="18" />
<subreportParameter name="invoiceId">
<subreportParameterExpression><![CDATA[$P{invoice_id}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "run-details.jasper"]]></subreportExpression>
</subreport>
<subreport>
<reportElement x="435" y="9" width="161" height="15" />
<subreportParameter name="invoiceId">
<subreportParameterExpression><![CDATA[$P{invoice_id}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "invoice-period-31.jasper"]]></subreportExpression>
</subreport>
<staticText>
<reportElement x="185" y="28" width="100" height="15" />
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Gesprächsnachweis]]></text>
</staticText>
<subreport>
<reportElement x="6" y="57" width="590" height="43" />
<subreportParameter name="invoiceId">
<subreportParameterExpression><![CDATA[$P{invoice_id}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="entityId">
<subreportParameterExpression><![CDATA[$P{entity_id}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "usage-31-de-details.jasper"]]></subreportExpression>
</subreport>
</band>
</pageHeader>
<pageFooter>
<band height="33">
<textField>
<reportElement x="195" y="15" width="80" height="15" />
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Seite "+$V{PAGE_NUMBER}+" von "]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="275" y="15" width="40" height="15" />
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<lastPageFooter>
<band height="33">
<textField>
<reportElement x="205" y="18" width="80" height="15" />
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Seite "+$V{PAGE_NUMBER}+" von "]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="285" y="18" width="40" height="15" />
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</lastPageFooter>
<summary>
<band height="20"/>
</summary>
Subreport code:
<?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="Usage Rport" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" >
<property name="com.jasperassistant.designer.GridHeight" value="12"/>
<property name="com.jasperassistant.designer.GridWidth" value="12"/>
<property name="com.jasperassistant.designer.SnapToGrid" value="false"/>
<property name="com.jasperassistant.designer.Grid" value="false"/>
<import value="org.joda.time.DateTime"/>
<parameter name="invoice_id" class="java.lang.Integer"/>
<parameter name="entity_id" class="java.lang.Integer"/>
<parameter name="entityCity" class="java.lang.String"/>
<parameter name="customerCity" class="java.lang.String"/>
<parameter name="entityPhoneCountryCode" class="java.lang.String"/>
<parameter name="entityPhoneAreaCode" class="java.lang.String"/>
<parameter name="entityPhoneContry" class="java.lang.String"/>
<parameter name="invoiceDate" class="java.lang.String"/>
<parameter name="invoiceDueDate" class="java.lang.String"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["D:\\Ravi Workspace\\Openbrm\\open-brm-openbrm-2.0\\descriptors\\reports\\usage\\"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select e.calling_number,e.duration,e.call_start_date,e.cost,e.destination_number,e.destination_descr,co.first_name,co.last_name,b.id as user_id from swiss_cdr_event e join order_process o join base_user b on b.id=e.user_id and e.order_id = o.order_id join contact co on e.user_id=co.user_id where o.invoice_id=$P{invoice_id} and b.entity_id=$P{entity_id} order by e.call_start_date asc;]]>
</queryString>
<field name="calling_number" class="java.lang.String"/>
<field name="destination_number" class="java.lang.String"/>
<field name="duration" class="java.lang.Integer"/>
<field name="cost" class="java.math.BigDecimal"/>
<field name="call_start_date" class="java.sql.Timestamp"/>
<field name="destination_descr" class="java.lang.String"/>
<field name="first_name" class="java.lang.String"/>
<field name="last_name" class="java.lang.String"/>
<field name="user_id" class="java.lang.Integer"/>
<variable name="total" class="java.math.BigDecimal" calculation="Sum">
<variableExpression><![CDATA[$F{cost}]]></variableExpression>
</variable>
<title>
<band height="111"/>
</title>
<columnHeader>
<band height="33">
<staticText>
<reportElement x="12" y="10" width="62" height="15" />
<textElement>
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Datum/Uhrzeit]]></text>
</staticText>
<staticText>
<reportElement x="240" y="10" width="85" height="15" />
<textElement>
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Destination]]></text>
</staticText>
<staticText>
<reportElement x="450" y="10" width="42" height="15" />
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Menge]]></text>
</staticText>
<staticText>
<reportElement x="90" y="10" width="62" height="15" />
<text><![CDATA[Anruf von]]></text>
</staticText>
<staticText>
<reportElement x="163" y="10" width="49" height="14" />
<text><![CDATA[Service]]></text>
</staticText>
<staticText>
<reportElement x="334" y="10" width="100" height="15" />
<text><![CDATA[Rufnummer]]></text>
</staticText>
<staticText>
<reportElement x="514" y="10" width="47" height="15" />
<text><![CDATA[Betrag]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20">
<textField>
<reportElement x="360" y="3" width="193" height="16" />
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA[new DecimalFormat("#,##0.00").format($F{cost})]]></textFieldExpression>
</textField>
<textField>
<reportElement x="12" y="3" width="96" height="16" />
<textElement>
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("dd-MM-yyyy").format($F{call_start_date})]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="242" y="3" width="121" height="16" />
<textElement>
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{destination_descr}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="60" y="3" width="96" height="16" />
<textElement>
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("HH:mm:ss").format($F{call_start_date})]]></textFieldExpression>
</textField>
<textField>
<reportElement x="450" y="4" width="100" height="16" />
<textElement>
<font size="9"/>
</textElement>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{duration}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="302" y="0" width="129" height="20" />
<subreportParameter name="invoiceId">
<subreportParameterExpression><![CDATA[$P{invoice_id}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "entity-details-31.jasper"]]></subreportExpression>
</subreport>
<textField>
<reportElement x="98" y="0" width="90" height="15" />
<textFieldExpression><![CDATA[$P{entityCity}]]></textFieldExpression>
</textField>
</band>
</detail>
<summary>
<band height="80">
<staticText>
<reportElement x="242" y="6" width="92" height="15" />
<text><![CDATA[Total]]></text>
</staticText>
<textField>
<reportElement x="431" y="6" width="100" height="15" />
<textElement textAlignment="Right">
<font size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{total} == null ? "0.00" : new DecimalFormat ("#,##0.00").format($V{total})]]></textFieldExpression>
</textField>
</band>
</summary>
As looking into your jrxml, You also have to pass $P{entity_id} to your sub_report. Currently you are passing only invoice id $P{invoice_id}. As your sub report sql is working on two parameter $P{invoice_id} and $P{entity_id}. if you are not passing it will pick default value or null (if no default value).
One more suggestion, sub report should contain only those band which is required and arrange your text field properly otherwise you will get excel column formating issue when you try to download in excel.
When you click on subreport and select properties then you will image like in first.
Now click on parameters in subreport tab of properties. Please see the second image.
there are three subreport in your main jrxml.
1) run-details.jrxml
Subreport parameter map in main jrxml
invoiceId : $P{invoice_id}
2) invoice-period-31.jrxml
Subreport parameter map in main jrxml
invoiceId : $P{invoice_id}
3) usage-31-de-details.jrxml
Subreport parameter map in main jrxml
invoiceId : $P{invoice_id}
I can see in 3 subreport parameter name is invoice_id. So you should change to
Subreport parameter map in main jrxml
invoice_id : $P{invoice_id}
And Also 3 sub report is working on entity_id parameter. you also have to pass that value.
Now
Subreport parameter map in main jrxml
invoice_id : $P{invoice_id}
entity_id : $P{entity_id}
I am not sure what parameter name is used in another subreport.

Show subreport independent of master datasource (master report) in ireport

Well, i have a Master and a SubReport where in master report i have 2 detail bands. In first detail band i put the "main datasource" (from fillReport), and in detail band 2 i put the subreport (datasource from a param).
My master report is configured to display "All Sections, No Detail" but the problem is that when "main datasource" dont have records the subreport isn't showed. I need show subreport detail independent of content of "main datasource".
How can i do it?
This is my report XML:
<?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="rf002" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="575" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="10" uuid="4436a245-e7f4-426f-aabc-806179a89e8a">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="84"/>
<parameter name="pathSubreport" class="java.lang.String">
<defaultValueExpression><![CDATA["/home/ronaldo/workspace/sender/src/main/webapp/WEB-INF/report/"]]></defaultValueExpression>
</parameter>
<parameter name="titulo" class="java.lang.String"/>
<parameter name="endereco" class="java.lang.String"/>
<parameter name="cep" class="java.lang.String"/>
<parameter name="estado" class="java.lang.String"/>
<parameter name="cidade" class="java.lang.String"/>
<parameter name="razaoSocial" class="java.lang.String"/>
<parameter name="pathLogomarca" class="java.lang.String"/>
<parameter name="usuario" class="java.lang.String"/>
<parameter name="dataFechamento" class="java.util.Date"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["/home/ronaldo/workspace/odontonew/src/main/webapp/WEB-INF/report/"]]></defaultValueExpression>
</parameter>
<parameter name="totaltt" class="java.lang.Double"/>
<parameter name="dentista" class="br.com.odontonew.bean.Dentista"/>
<parameter name="historicosCaixaDentista" class="java.lang.Object"/>
<parameter name="historicosPagamentoOrcamento" class="java.lang.Object"/>
<parameter name="parcelasAVencerHoje" class="java.lang.Object"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="nomePaciente" class="java.lang.String">
<fieldDescription><![CDATA[orcamento.paciente.pessoaFisica.nome]]></fieldDescription>
</field>
<field name="dataHoraConsulta" class="java.sql.Timestamp">
<fieldDescription><![CDATA[dataHoraAgendada]]></fieldDescription>
</field>
<field name="idConsulta" class="java.lang.Integer">
<fieldDescription><![CDATA[id]]></fieldDescription>
</field>
<field name="nomeProcedimento" class="java.lang.String">
<fieldDescription><![CDATA[itens.itemTabelaProcedimento.procedimento.nome]]></fieldDescription>
</field>
<field name="isConcluido" class="java.lang.Boolean">
<fieldDescription><![CDATA[itens.concluido]]></fieldDescription>
</field>
<group name="consulta">
<groupExpression><![CDATA[$F{idConsulta}]]></groupExpression>
<groupHeader>
<band height="33">
<textField isBlankWhenNull="true">
<reportElement x="8" y="16" width="276" height="14" uuid="fd8d4206-2b32-4619-a340-95b4357b6a1a"/>
<textElement>
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{nomePaciente}]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="true">
<reportElement x="292" y="16" width="184" height="14" uuid="e7b1cb6b-c4c4-42ab-b028-69e720f43f1f"/>
<textElement>
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{dataHoraConsulta}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="9" y="5" width="149" height="12" uuid="bf06788d-c15a-4547-8a6e-df2ae3be70ea"/>
<textElement>
<font size="8"/>
</textElement>
<text><![CDATA[Paciente da Consulta]]></text>
</staticText>
<staticText>
<reportElement x="292" y="5" width="149" height="12" uuid="4d788cff-e015-4085-a320-8924a6a6b48c"/>
<textElement>
<font size="8"/>
</textElement>
<text><![CDATA[Data e Hora da Consulta]]></text>
</staticText>
</band>
</groupHeader>
</group>
<background>
<band/>
</background>
<title>
<band height="90" splitType="Stretch">
<subreport>
<reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="575" height="90" uuid="0999674d-9841-41dd-97c2-226b2186b45e"/>
<subreportParameter name="pathLogomarca">
<subreportParameterExpression><![CDATA[$P{pathLogomarca}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="cidade">
<subreportParameterExpression><![CDATA[$P{cidade}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="titulo">
<subreportParameterExpression><![CDATA[$P{titulo}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="cep">
<subreportParameterExpression><![CDATA[$P{cep}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="estado">
<subreportParameterExpression><![CDATA[$P{estado}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="usuario">
<subreportParameterExpression><![CDATA[$P{usuario}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="razaoSocial">
<subreportParameterExpression><![CDATA[$P{razaoSocial}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="endereco">
<subreportParameterExpression><![CDATA[$P{endereco}]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA[$P{pathSubreport}+"headerTemplate.jasper"]]></subreportExpression>
</subreport>
</band>
</title>
<columnHeader>
<band height="76">
<rectangle>
<reportElement x="0" y="27" width="575" height="49" backcolor="#DFDCDC" uuid="4e1f0879-74cc-46bf-8fb2-bb60ea002018"/>
<graphicElement>
<pen lineWidth="0.0"/>
</graphicElement>
</rectangle>
<staticText>
<reportElement x="416" y="57" width="140" height="14" uuid="afd4b28f-8b51-43d1-a9a2-c4acbb1f6c63"/>
<textElement textAlignment="Center">
<font isBold="true"/>
</textElement>
<text><![CDATA[Concluído]]></text>
</staticText>
<staticText>
<reportElement x="7" y="57" width="397" height="14" uuid="2c8deaa8-9d46-4c31-a542-e41b7f959615"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Procedimento]]></text>
</staticText>
<staticText>
<reportElement x="9" y="34" width="397" height="14" uuid="6578bf15-8e39-4a0d-9fc6-5c45fb5ad566"/>
<textElement>
<font isBold="true" isItalic="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Consultas Realizadas]]></text>
</staticText>
<textField pattern="dd/MM/yyyy" isBlankWhenNull="true">
<reportElement x="120" y="5" width="165" height="14" uuid="4a835664-78da-4231-b7de-a21b730b4a7e"/>
<textFieldExpression><![CDATA[$P{dataFechamento}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="6" y="5" width="112" height="14" uuid="8420da3e-43c6-49a6-a688-89d50b5095a7"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Data Fechamento:]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="21">
<textField isBlankWhenNull="true">
<reportElement x="10" y="4" width="394" height="14" uuid="0f1109a2-30d7-4789-bb6f-54d066856cf3"/>
<textFieldExpression><![CDATA[$F{nomeProcedimento}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="425" y="1" width="131" height="14" uuid="6b67a6ee-6732-48b6-b79e-12f6e371c35e"/>
<textFieldExpression><![CDATA[$F{isConcluido} ? "Sim" : "Não"]]></textFieldExpression>
</textField>
</band>
<band height="173">
<subreport>
<reportElement x="0" y="0" width="575" height="73" uuid="871e12c8-2633-4d76-8d65-ce253710c4eb"/>
<dataSourceExpression><![CDATA[$P{historicosPagamentoOrcamento}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "rf002_historicosPagamentoOrcamento.jasper"]]></subreportExpression>
</subreport>
<subreport>
<reportElement x="0" y="94" width="575" height="69" uuid="338fd0af-a2ca-453e-8777-0f49698ebb44"/>
<dataSourceExpression><![CDATA[$P{historicosCaixaDentista}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "rf002_historicosCaixa.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<lastPageFooter>
<band height="185" splitType="Stretch">
<textField evaluationTime="Report">
<reportElement x="516" y="155" width="40" height="20" uuid="3cd272a2-adde-48f0-9f1e-5d7f007b9a1f"/>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="436" y="155" width="80" height="20" uuid="7cc86ec7-b620-4c95-9147-1410b1a22054"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
</band>
</lastPageFooter>
</jasperReport>
SOLUTION
After a lot of research i saw that my concept about "main report" and "subreport" is wrong. When we have a "main report" (associated with a main datasource) the correct is that all "subreport" is directly associated with this. So, i created 3 subreports and pass all datasources like a 'param'. In JasperManagerFillReport i passed a "JREmptyDataSource" to avoid the blank page because "main datasource" don't have any content.
You can try setting WhenNoData property to NoDataSection. Then, in the No Data band add what you want.
Also, check what happens to the subreports when the parameters you send as dataSourceExpression are empty (if they are).

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

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