Jasper server subreport in detail band - jasper-reports

I need to create subreports in detail band, i am passing same datasource of main report to subreports.
Issue i am facing as it goes in to subreport it increments the index counter which does not allow to add remaining subreport.
MainReport.jrxml
<group name="Account Summary">
<groupHeader>
<band height="100" splitType="Stretch">
<printWhenExpression><![CDATA[$F{accountSummary.hasRepots}]]></printWhenExpression>
<subreport isUsingCache="false">
<reportElement x="28" y="0" width="540" height="100" isRemoveLineWhenBlank="true"/>
<subreportParameter name="accountSummary">
<subreportParameterExpression><![CDATA[$F{accountSummary.hasRepots}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "SubReport.jasper"]]></subreportExpression>
</subreport>
</band>
</groupHeader>
</group>
SubReport.jrxml
<detail>
<band height="100" splitType="Stretch">
<subreport isUsingCache="false">
<reportElement positionType="Float" x="0" y="0" width="540" height="100" isRemoveLineWhenBlank="true"/>
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + $F{subreportFileName}]]></subreportExpression>
</subreport>
</band>
</detail>
Where i pass $F{subreportFileName} from my datasource for example "SubSubReport.jrxml", but it only displays first report, i guess due to my index counter runs out in my sub-sub report so my sub report detail band doesn't go for each element.
SubSubReport.jrxml
<field name="chartData.label" class="java.lang.String"/>
<field name="chartData.value" class="java.lang.Float"/>
<field name="value1" class="java.lang.String"/>
<field name="value2" class="java.lang.String"/>
<field name="value3" class="java.lang.String"/>
<pageHeader>
<band height="114" splitType="Stretch">
<staticText>
<reportElement style="lbl-light-golden" x="12" y="19" width="170" height="67"/>
<textElement>
<font size="26"/>
</textElement>
<text><![CDATA[Some Label]]></text>
</staticText>
<pieChart>
<chart evaluationTime="Band">
<reportElement x="272" y="0" width="268" height="114"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend position="Left"/>
</chart>
<pieDataset>
<keyExpression><![CDATA[$F{chartData.label}]]></keyExpression>
<valueExpression><![CDATA[$F{chartData.value}]]></valueExpression>
<labelExpression><![CDATA[null]]></labelExpression>
</pieDataset>
<piePlot isShowLabels="false" isCircular="true">
<plot/>
<itemLabel/>
</piePlot>
</pieChart>
</band>
</pageHeader>
<columnHeader>
<band height="18" splitType="Stretch">
<line>
<reportElement x="0" y="1" width="540" height="1"/>
</line>
<staticText>
<reportElement style="lbl-black-table-header" x="12" y="4" width="158" height="14"/>
<textElement/>
<text><![CDATA[Header 1]]></text>
</staticText>
<staticText>
<reportElement style="lbl-black-table-header" x="205" y="4" width="199" height="14"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Header 2]]></text>
</staticText>
<staticText>
<reportElement style="lbl-black-table-header" x="445" y="4" width="74" height="13"/>
<textElement textAlignment="Center"/>
<text><![CDATA[Header 3]]></text>
</staticText>
<line>
<reportElement x="0" y="17" width="540" height="1"/>
</line>
</band>
</columnHeader>
<detail>
<band height="18" splitType="Stretch">
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" x="12" y="1" width="158" height="16"/>
<textElement/>
<textFieldExpression><![CDATA[$F{value1}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" x="205" y="1" width="199" height="16"/>
<textElement textAlignment="Right">
<font isStrikeThrough="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{value2}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" x="445" y="1" width="74" height="16"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{value3}]]></textFieldExpression>
</textField>
</band>
</detail>
Also i tried using Groups instead of detail band as follows in "SubReport.jrxml"
SubReport.jrxml
<group name="Sub report 1">
<groupHeader>
<band height="100" splitType="Stretch">
<subreport isUsingCache="false">
<reportElement positionType="Float" x="0" y="0" width="540" height="100" isRemoveLineWhenBlank="true"/>
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "SubSubReport.jasper"]]></subreportExpression>
</subreport>
</band>
</groupHeader>
</group>
<group name="Sub report 2">
<groupHeader>
<band height="200" splitType="Stretch">
<staticText>
<reportElement x="110" y="10" width="100" height="20"/>
<textElement/>
<text><![CDATA[Sub report 2]]></text>
</staticText>
<subreport isUsingCache="false">
<reportElement positionType="Float" x="0" y="40" width="540" height="100" isRemoveLineWhenBlank="true"/>
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "SubSubReport1.jasper"]]></subreportExpression>
</subreport>
</band>
</groupHeader>
</group>
It prints "Sub report 2" label but no success with printing "SubSubReport1.jasper"
What am i doing wrong any suggestions or any direction which can help.

the report data source should never be used to feed a subreport. The REPORT_DATA_SOURCE is a data source that is a consumable object.
This means that is usable for feeding a report only once. Therefore, the parameter technique is not suitable when every record of the master report has its own subreport (unless there is only one record in the master report). I think this could be the reason that you see only one.

Related

Issue with showing data in the second page of report

I am trying to create a jasper report with a chart and data. But I am unable to display data in the second page. The header is also not displaying properly.
My report has the following elements/ bands :
1. A page header which shows a logo and from and to date fields
2. column header which has a graph/ chart
3. in the details band has data displayed using custom table structure (created with text fields).
4. and finally there is a page footer.
Please find the code below:
<?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="peopleAvg" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1bb591b9-6043-4a15-b759-36bd5afbc1c2">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="fromDate" class="java.lang.String"/>
<parameter name="toDate" class="java.lang.String"/>
<parameter name="orgLogo" class="java.io.InputStream"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="slno" class="java.lang.String"/>
<field name="hour" class="java.lang.String"/>
<field name="insideProductivity" class="java.lang.Double"/>
<field name="outsideProductivity" class="java.lang.Double"/>
<field name="day" class="java.lang.Double"/>
<field name="total" class="java.lang.Double"/>
<pageHeader>
<band height="66" splitType="Stretch">
<staticText>
<reportElement x="0" y="12" width="123" height="17" uuid="2ce05d01-f1ca-46ec-b055-6a786d6180a9"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[People Avg Productivity]]></text>
</staticText>
<staticText>
<reportElement x="0" y="42" width="52" height="21" uuid="1190e3e7-8e6e-4c07-a328-31ff29e54d3c"/>
<text><![CDATA[From Date:]]></text>
</staticText>
<textField>
<reportElement x="56" y="42" width="81" height="21" uuid="6dd52950-dbbb-48bd-8879-82cc00ad4f4c"/>
<textFieldExpression><![CDATA[$P{fromDate}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="138" y="42" width="47" height="21" uuid="ee86580c-820d-4116-94e5-eb5f745acf14"/>
<text><![CDATA[To Date:]]></text>
</staticText>
<textField>
<reportElement x="185" y="42" width="88" height="21" uuid="9d13a4d5-bddf-4bac-a44f-e24da7b38a0c"/>
<textFieldExpression><![CDATA[$P{toDate}]]></textFieldExpression>
</textField>
<image>
<reportElement x="480" y="0" width="70" height="59" uuid="a967b7a0-2bb3-41c9-a4a8-9597d26d4996"/>
<imageExpression><![CDATA[$P{orgLogo}]]></imageExpression>
</image>
<line>
<reportElement x="0" y="65" width="555" height="1" uuid="8af4ab23-161b-4419-ad6e-7056340a2023"/>
</line>
</band>
</pageHeader>
<columnHeader>
<band height="267" splitType="Stretch">
<stackedBar3DChart>
<chart evaluationTime="Report">
<reportElement x="0" y="9" width="555" height="210" uuid="8ff37812-d1a7-49ae-b62c-f10cb1a69a02">
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA["Inside Mine"]]></seriesExpression>
<categoryExpression><![CDATA[$F{hour}]]></categoryExpression>
<valueExpression><![CDATA[$F{insideProductivity}]]></valueExpression>
<labelExpression><![CDATA[$F{insideProductivity}+""]]></labelExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA["Outside Mine"]]></seriesExpression>
<categoryExpression><![CDATA[$F{hour}]]></categoryExpression>
<valueExpression><![CDATA[$F{outsideProductivity}]]></valueExpression>
<labelExpression><![CDATA[$F{outsideProductivity}+""]]></labelExpression>
</categorySeries>
</categoryDataset>
<bar3DPlot>
<plot labelRotation="66.0"/>
<itemLabel/>
<categoryAxisFormat labelRotation="66.0">
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</valueAxisFormat>
</bar3DPlot>
</stackedBar3DChart>
<staticText>
<reportElement x="97" y="228" width="58" height="30" uuid="dadece34-824f-481c-aa40-702eececcfa0"/>
<text><![CDATA[Time In Hrs]]></text>
</staticText>
<staticText>
<reportElement x="167" y="228" width="89" height="30" uuid="9f8ff91e-99d8-4fdd-98cb-4d6c09ac93f3"/>
<text><![CDATA[Mine In(Avg Time in Hrs)]]></text>
</staticText>
<staticText>
<reportElement x="267" y="228" width="100" height="30" uuid="fb564933-5603-440a-b4bb-9e7ffea3a60a"/>
<text><![CDATA[Mine Out(Avg Time In Hrs)]]></text>
</staticText>
<staticText>
<reportElement x="38" y="228" width="50" height="30" uuid="5c46f7d8-e33d-40ef-b266-be837cad3bf3"/>
<text><![CDATA[Sl.No]]></text>
</staticText>
<staticText>
<reportElement x="387" y="228" width="61" height="30" uuid="638b6be5-7679-45c9-a798-61e439710d14"/>
<text><![CDATA[Total Hours]]></text>
</staticText>
<staticText>
<reportElement x="137" y="187" width="73" height="30" uuid="94548637-903d-42b1-8be3-a59c9370fbf6"/>
<text><![CDATA[Time (in hrs)]]></text>
</staticText>
<staticText>
<reportElement x="2" y="60" width="18" height="65" uuid="01f4f72c-1f89-4dc9-a59f-bbc8e1523c0d"/>
<textElement rotation="Left"/>
<text><![CDATA[No of Hours]]></text>
</staticText>
<line>
<reportElement x="37" y="228" width="411" height="1" uuid="8097c975-2f0d-494e-a6b3-eac6c0049aea"/>
</line>
<line>
<reportElement x="38" y="227" width="1" height="38" uuid="967a9b95-64bc-4979-a11a-d12cb3204c27"/>
</line>
<line>
<reportElement x="448" y="227" width="1" height="39" uuid="22cfbc0d-5e9b-4853-a5c3-249210cbc611"/>
</line>
<line>
<reportElement x="88" y="226" width="1" height="39" uuid="d906ae7c-2395-4a03-9015-f38054af4239"/>
</line>
<line>
<reportElement x="162" y="228" width="1" height="37" uuid="2fcdb73a-f506-4425-8404-b12bbdf37759"/>
</line>
<line>
<reportElement x="263" y="228" width="1" height="37" uuid="a828608f-c02d-42d5-867b-6c4b41cc7ba3"/>
</line>
<line>
<reportElement x="380" y="227" width="1" height="39" uuid="a41cc5e7-d5ff-4ce1-aa45-110ce737febd"/>
</line>
</band>
</columnHeader>
<detail>
<band height="37" splitType="Stretch">
<textField pattern="" isBlankWhenNull="true">
<reportElement x="42" y="3" width="42" height="30" isPrintWhenDetailOverflows="true" uuid="4b14159d-88e2-403f-8d23-4348a9071edd"/>
<textFieldExpression><![CDATA[$F{slno}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="99" y="3" width="56" height="29" isPrintWhenDetailOverflows="true" uuid="c5f091cb-1dd4-42aa-b293-661fa30447d5"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{hour}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="166" y="4" width="90" height="30" isPrintWhenDetailOverflows="true" uuid="3e402bb8-2c7d-44d2-88f7-bfd3923fa79b"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{insideProductivity}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="266" y="5" width="100" height="30" isPrintWhenDetailOverflows="true" uuid="feb73c78-3f84-49ec-867b-aa4d0fa87aa6"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{outsideProductivity}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="386" y="5" width="60" height="30" isPrintWhenDetailOverflows="true" uuid="20a6c8ca-ce41-4ba1-a877-b84ec62401bf"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{total}]]></textFieldExpression>
</textField>
<line>
<reportElement x="38" y="-2" width="1" height="38" uuid="1dd9a050-2aee-4bf9-a05d-4191795c3b2c"/>
</line>
<line>
<reportElement x="88" y="-1" width="1" height="35" uuid="819297ed-658a-4e87-b2de-6de1c4ab0f9f"/>
</line>
<line>
<reportElement x="162" y="-1" width="1" height="35" uuid="683ef7c9-014a-4ece-8b8c-0f73238728fc"/>
</line>
<line>
<reportElement x="263" y="-3" width="1" height="40" uuid="1f47437f-6ee5-4281-aa7d-3d005ba8c3ba"/>
</line>
<line>
<reportElement x="380" y="0" width="1" height="37" uuid="c1d15bd7-3d55-4da6-8787-a6df37d0f892"/>
</line>
<line>
<reportElement x="448" y="-1" width="1" height="37" uuid="12959f57-ba8d-463f-9967-6c573a690dcf"/>
</line>
<line>
<reportElement x="39" y="35" width="410" height="1" uuid="5b39727f-2b4e-47d8-80c1-0b28afb08f72"/>
</line>
</band>
</detail>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
</jasperReport>
Please see the image below. At the bottom you will notice that the header printed is incomplete and also there is no more data in the page
Can some please help me here.
I could solve this problem. Actually there was a problem with the logo that I have used here. Due to this it was throwing an error. All I did was just change a couple of properties for the image and had to rerun the report. That is all. Sorry. And thank you.

Resetting page number based on grouping

I wonder if it is possible to reset page number based on grouping?
My idea is like group 1 having 3 pages which will show Page 1 of 3, page 2 of 3 and page 3 of 3. And group 2 having 1 page which will show Page 1 of 1.
So the display will be:
Page 1 of 3
Page 2 of 3
Page 3 of 3
page 1 of 1
Is it possible to do that? I have searched all the web seems like can't find any clue and steps to do.
Source
<queryString language="SQL">
<![CDATA[Select * from Persons where ID = $P{ID}]]>
</queryString>
<field name="ID" class="java.lang.Object"/>
<group name="myGroup" isStartNewPage="true" isResetPageNumber="true">
<groupHeader>
<band height="224">
<subreport>
<reportElement x="300" y="135" width="270" height="60" uuid="1f20858d-c055-41e2-9a60-bbc040ae6485"/>
<subreportParameter name="ID_PERSON">
<subreportParameterExpression><![CDATA[$F{ID}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["subreport_1.jasper"]]></subreportExpression>
</subreport>
<staticText>
<reportElement x="280" y="10" width="100" height="30" uuid="dacdfcd9-150b-419d-ba3b-b56949cd518d"/>
<text><![CDATA[Group 1]]></text>
</staticText>
<break>
<reportElement x="0" y="210" width="99" height="1" uuid="a77bf8e0-98ea-4167-b852-f2cb5f6e1cf6"/>
</break>
<staticText>
<reportElement x="280" y="58" width="300" height="30" uuid="df9536c9-6584-43b3-b8b9-45fd0c0b95a6"/>
<text><![CDATA[This report is to testing the grouping.]]></text>
</staticText>
<break>
<reportElement x="0" y="111" width="100" height="1" uuid="6cda26ee-6e49-4e94-8d58-5d5dd42745e6"/>
</break>
</band>
</groupHeader>
<groupFooter>
<band height="50"/>
</groupFooter>
</group>
<group name="myGroup2" isStartNewPage="true" isResetPageNumber="true">
<groupHeader>
<band height="130">
<subreport>
<reportElement x="270" y="60" width="300" height="60" uuid="5663a0dc-9b14-485b-84a9-21b5e0c3b98d"/>
<subreportParameter name="ID_PERSON">
<subreportParameterExpression><![CDATA[$F{ID}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["subreport_2.jasper"]]></subreportExpression>
</subreport>
<staticText>
<reportElement x="280" y="20" width="100" height="30" uuid="eaa5ee0f-c0e5-4555-b321-a4db52b4efde"/>
<text><![CDATA[Group 2]]></text>
</staticText>
</band>
</groupHeader>
<groupFooter>
<band height="58"/>
</groupFooter>
</group>
<pageFooter>
<band height="57" splitType="Stretch">
<textField evaluationTime="Group" evaluationGroup="myGroup">
<reportElement x="400" y="10" width="100" height="30" uuid="215676d9-e972-45bd-adad-b79c1fa27112"/>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="310" y="10" width="110" height="30" uuid="75a82ec2-a8ed-46dd-b5a1-147c450e32f8"/>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>

Why am I unable to sum up javabean subitem's value in jrtable?

I get this exception when tying to sum nested column values
net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :
1. Field not found : episodeCount
2. Variable not found : episodeTotal
How would I pass the above parameter/variable(s) to the sub dataset?
My jrxml file
<subDataset name="dataset1">
<field name="orderItem" class="com.blahblah.OrderItemPDF">
<fieldDescription><![CDATA[_THIS]]></fieldDescription>
</field>
</subDataset>
<field name="orderItems" class="java.util.Collection"/>
<field name="episodeCount" class="java.lang.Integer">
<fieldDescription><![CDATA[$F{orderItem}.getEpisodeCount()]]></fieldDescription>
</field>
<variable name="episodeTotal" class="java.lang.Integer" calculation="Sum">
<variableExpression><![CDATA[$F{episodeCount}]]></variableExpression>
</variable>
<title>
<band height="113" splitType="Stretch">
</band>
</title>
<pageHeader>
<band height="360">
<componentElement>
<reportElement x="67" y="181" width="360" height="100"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="dataset1">
<dataSourceExpression>
<![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{orderItems})]]></dataSourceExpression>
</datasetRun>
<jr:column width="130">
<jr:tableHeader height="30">
<staticText>
<reportElement x="0" y="0" width="130" height="20"/>
<textElement/>
<text><![CDATA[Media Families]]></text>
</staticText>
</jr:tableHeader>
<jr:detailCell height="20">
<textField>
<reportElement x="0" y="0" width="130" height="20"/>
<textElement/>
<textFieldExpression>
<![CDATA[$F{orderItem}.getMediaFamilyName()]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="130">
<jr:tableHeader height="30">
<staticText>
<reportElement x="0" y="0" width="130" height="20"/>
<textElement/>
<text><![CDATA[Episodes]]></text>
</staticText>
</jr:tableHeader>
<jr:detailCell height="20">
<textField>
<reportElement x="0" y="0" width="130" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{orderItem}.getEpisodeCount()]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="60">
<jr:tableHeader height="30">
<staticText>
<reportElement x="0" y="0" width="60" height="20"/>
<textElement/>
<text><![CDATA[AdUnits]]></text>
</staticText>
</jr:tableHeader>
<!--<jr:columnFooter height="20">-->
<!--<textField>-->
<!--<reportElement x="0" y="0" width="130" height="20"/>-->
<!--<textElement/>-->
<!--<textFieldExpression><![CDATA[$V{episodeTotal}]]></textFieldExpression>-->
<!--</textField>-->
<!--</jr:columnFooter>-->
<jr:detailCell height="20">
<textField>
<reportElement x="0" y="0" width="60" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{orderItem}.getAdUnitCount()]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</pageHeader>
<columnHeader>jas
</columnHeader>
<detail>
<band/>
</detail>
When using a subDataset you need to define all your fields, parameter and variables inside of the subDataset. You can not reference fields, parameters and variables that are outside.
In your example the definition of the variable inside the subDataset would be something like this
<subDataset name="dataset1">
<field name="orderItem" class="com.blahblah.OrderItemPDF">
<fieldDescription><![CDATA[_THIS]]></fieldDescription>
</field>
<variable name="episodeTotal" class="java.lang.Integer" calculation="Sum">
<variableExpression><![CDATA[$F{orderItem}.getEpisodeCount()]]></variableExpression>
</variable>
</subDataset>
The variables and parameters and resources that are defined in outside of jrxml cannot be access from Data Set or Table directly. You need to explicitly pass these as parameter to the dataset. Otherwise, it is getting Not found error.
Something similar to
Passing main parameter to sub-datasets in JasperStudio

Trying to get Jaspersoft Studio to Read Excel Numeric Values

I am using Jaspersoft Studio to create a JasperReports's report using an Excel file as data source (I have a couple of columns in excel with numeric values to which i have assigned the class java.lang.Number in fields). But when previewing the report, I get the following the error
"net.sf.jasperreports.engine.JRException: unable to get value for field 'Hours' of class java.lang.Number"
Any inputs please?
Here is my jrxml file
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 5.6.1.final using JasperReports Library version 5.6.1 -->
<!-- 2014-09-25T18:35:44 -->
<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="Leaf_Grey" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="896e484a-2240-4304-afcc-7290c150d8b7">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter (4)"/>
<style name="Title" fontName="Arial" fontSize="26" isBold="true" pdfFontName="Helvetica-Bold"/>
<style name="SubTitle" forecolor="#666666" fontName="Arial" fontSize="18"/>
<style name="Column header" forecolor="#666666" fontName="Arial" fontSize="12" isBold="true"/>
<style name="Detail" fontName="Arial" fontSize="12"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="Task" class="java.lang.String"/>
<field name="Site Name" class="java.lang.String"/>
<field name="Hours" class="java.lang.Number"/>
<field name="Minutes" class="java.lang.Number"/>
<field name="Status" class="java.lang.String"/>
<field name="Comments" class="java.lang.String"/>
<field name="Employee Name" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="70" splitType="Stretch">
<image>
<reportElement x="275" y="0" width="300" height="64" uuid="8636fef6-bee7-4ac4-9942-653e5c68326b"/>
<imageExpression><![CDATA["leaf_banner_gray.png"]]></imageExpression>
</image>
<staticText>
<reportElement style="Title" x="0" y="13" width="263" height="33" uuid="4370ee46-32ee-4993-8fc6-fff1a5cbbb10"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Leaf Gray Title]]></text>
</staticText>
<staticText>
<reportElement style="SubTitle" x="117" y="46" width="157" height="22" uuid="e0a627c7-e8b9-4efb-8e25-85fea9d9be9c"/>
<text><![CDATA[Leaf Gray SubTitle]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="36" splitType="Stretch">
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="35" width="555" height="1" uuid="8545dbd1-d876-4d96-8abf-d6b221e00a45"/>
<graphicElement>
<pen lineWidth="0.5" lineColor="#999999"/>
</graphicElement>
</line>
<staticText>
<reportElement style="Column header" x="0" y="19" width="79" height="15" uuid="cac2a980-c74e-44b0-b596-05d495272ccb"/>
<text><![CDATA[Task]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="79" y="19" width="79" height="15" uuid="d55bebe9-d167-4528-a78c-a5a41af89efc"/>
<text><![CDATA[Site Name]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="158" y="19" width="79" height="15" uuid="667ce640-c671-4337-8f0c-d23b3f4b273c"/>
<text><![CDATA[Hours]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="237" y="19" width="79" height="15" uuid="df472e1f-39fb-4b34-b0b3-0867407df860"/>
<text><![CDATA[Minutes]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="316" y="19" width="79" height="15" uuid="05e27ddd-a03c-4ad6-8596-5cfc00655de7"/>
<text><![CDATA[Status]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="395" y="19" width="79" height="15" uuid="cefa7fbe-75bd-4923-82a6-da21a13d4f58"/>
<text><![CDATA[Comments]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="474" y="19" width="79" height="15" uuid="090b77e6-6a38-43b4-8501-6e1c3e246764"/>
<text><![CDATA[Employee Name]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="16" splitType="Stretch">
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="15" width="555" height="1" uuid="9b18ea63-f82d-4ef1-872e-8fde09656872"/>
<graphicElement>
<pen lineWidth="0.5" lineColor="#999999"/>
</graphicElement>
</line>
<textField>
<reportElement style="Detail" x="0" y="0" width="79" height="15" uuid="1f24eaab-1923-419e-9262-79b6c2b80499"/>
<textFieldExpression><![CDATA[$F{Task}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Detail" x="79" y="0" width="79" height="15" uuid="f9b21e3a-3150-4744-a413-10cf734a2c3d"/>
<textFieldExpression><![CDATA[$F{Site Name}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Detail" x="158" y="0" width="79" height="15" uuid="867d0368-9589-4c6b-8502-f71224a11a4c"/>
<textFieldExpression><![CDATA[$F{Hours}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Detail" x="237" y="0" width="79" height="15" uuid="17715223-dbc6-462a-b80c-aeb54aa58932"/>
<textFieldExpression><![CDATA[$F{Minutes}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Detail" x="316" y="0" width="79" height="15" uuid="3a3115d3-420d-4411-88cc-30b41f67443e"/>
<textFieldExpression><![CDATA[$F{Status}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Detail" x="395" y="0" width="79" height="15" uuid="97194b34-07e1-49b4-aba0-af1efe7b9bf4"/>
<textFieldExpression><![CDATA[$F{Comments}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Detail" x="474" y="0" width="79" height="15" uuid="ba21b35b-74a9-45ee-862f-8752756350dd"/>
<textFieldExpression><![CDATA[$F{Employee Name}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch">
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="3" width="555" height="1" uuid="7d65af8c-8abe-40ae-9953-98342530289f"/>
<graphicElement>
<pen lineWidth="0.5" lineColor="#999999"/>
</graphicElement>
</line>
</band>
</columnFooter>
<pageFooter>
<band height="20" splitType="Stretch">
<textField>
<reportElement style="Column header" x="433" y="0" width="80" height="20" uuid="afe06d42-bf57-40c1-9cbb-6e8a04a641e6"/>
<textElement textAlignment="Right">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement style="Column header" x="513" y="0" width="40" height="20" uuid="ee38e653-d5c9-4269-93a3-b1dcd2685d2c"/>
<textElement>
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement style="Column header" x="0" y="0" width="197" height="20" uuid="af6b71ba-3c04-4b3c-9b70-e18e46b27ff4"/>
<textElement>
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>
And a sample excel file as follows:
Task Site Name Hours Minutes Status Comments Employee Name
Task A abc.com 3 45 Ongoing Easy Jim
Task B abc.com 1 20 Done Easy John
Task C abc.com 3 30 Ongoing Easy Jim
Task A abc.com 1 20 Done Easy John
Task D abc.com 3 45 Ongoing Easy Mary
Task A abc.com 1 20 Done Easy Stacy
Task E abc.com 3 30 Ongoing Easy Stacy
Task A abc.com 1 20 Done Easy Stacy
1) If the requirement is to change the Class to Number from String then, you need to click the checkbox "Use custom number pattern" and select a number pattern.
2) If there is no specific requirement, then its easy to select java.lang.Integer as the class for numbers. This will make the report work just fine.

is it possible print element only when its detail band is the last on page?

Is it possible, to get a condition, that I can print an element only when its detail band is the last on page in Jasper Reports?
We can have variable saying record number on the page. But how we get the calculated total record on each page?
This is done with the "reset type" on a variable
<?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="612" pageHeight="792" columnWidth="612" leftMargin="0" rightMargin="0" topMargin="10" bottomMargin="10" uuid="39852bd8-6125-4359-8d76-06927e7be492">
<queryString>
<![CDATA[SELECT ROWNUM N FROM dual CONNECT BY LEVEL <= 200 ]]>
</queryString>
<field name="N" class="java.math.BigDecimal"/>
<variable name="N_count_page" class="java.lang.Integer" resetType="Page" calculation="Count">
<variableExpression><![CDATA[$F{N}]]></variableExpression>
</variable>
<variable name="N_count_report" class="java.lang.Integer" calculation="Count">
<variableExpression><![CDATA[$F{N}]]></variableExpression>
</variable>
<title>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="93284d9f-1ee0-4a15-b227-31b55aa2e48b" x="0" y="0" width="376" height="20"/>
<textElement textAlignment="Center">
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Page Count"]]></textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
<band height="20">
<staticText>
<reportElement uuid="a7113fdd-591b-4fee-9123-981ab75c6fa6" mode="Opaque" x="0" y="0" width="100" height="20" forecolor="#FFFFFF" backcolor="#000000"/>
<textElement/>
<text><![CDATA[N]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20">
<textField>
<reportElement uuid="54bac746-4efb-4412-81bc-b4ba807c60fd" x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{N}]]></textFieldExpression>
</textField>
</band>
</detail>
<pageFooter>
<band height="50">
<staticText>
<reportElement uuid="4c685263-0ef7-4a68-a328-39901ef2806f" x="0" y="0" width="100" height="20"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Rows on page :]]></text>
</staticText>
<textField>
<reportElement uuid="c65214f1-82dc-476a-8439-087854bbc5c6" x="100" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$V{N_count_page}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="48b37aff-b169-4ca2-b9dd-30c026988f68" x="289" y="30" width="80" height="20"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement uuid="983ccfed-d783-429e-bc6c-3fa488b2e106" x="369" y="30" width="40" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<lastPageFooter>
<band height="64">
<staticText>
<reportElement uuid="240e2f86-991a-4fc1-941b-56cc43b28c25" x="0" y="24" width="100" height="20"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Rows on report :]]></text>
</staticText>
<textField>
<reportElement uuid="718d4481-4716-4071-9989-27d5119fb428" x="100" y="24" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$V{N_count_report}]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement uuid="f03359be-3bbe-4da8-9bd8-ac024aa6f289" x="369" y="44" width="40" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="ad4aa2c0-9ad8-4892-a16f-0bb584c93916" x="289" y="44" width="80" height="20"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<staticText>
<reportElement uuid="b4bdd29a-4ef9-46cc-a57a-df7577bdd73f" x="0" y="0" width="100" height="20"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Rows on page :]]></text>
</staticText>
<textField>
<reportElement uuid="39952747-170c-4747-8e2c-0e12ab608ae9" x="100" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$V{N_count_page}]]></textFieldExpression>
</textField>
</band>
</lastPageFooter>
</jasperReport>