Jasper Report graph in iReport repeating - charts

I have a line graph in iReport which is incrementally repeating in every page, that is, if the graph has 30 x/y pairs (this is dynamic), the report will have 30 pages, of which the first will have just one value, the 2nd two values, and so on. Only the last one will contain the complete graph.
Questions "chart repeat many time" and "Problem with charting using JasperReport" and "How to print the grand total only in the last page of a very long report?" did not solve my problem. I understand that putting the chart in the Detail section makes the chart repeat, but putting it in the Summary, Footer, lastPageFooter, Title, etc. sections makes it display only one value. Same when I put it in the Detail section and use <printWhenExpression>.
My 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="nodes-allarmipersistenti" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<field name="day" class="java.lang.Number"/>
<field name="month" class="java.lang.String"/>
<field name="year" class="java.lang.String"/>
<field name="dsunita" class="java.lang.String"/>
<field name="valueNumber" class="java.lang.Number"/>
<field name="logo" class="java.lang.String"/>
<field name="today" class="java.lang.String"/>
<field name="option" class="java.lang.String"/>
<title>
<band height="89">
<staticText>
<reportElement mode="Opaque" x="0" y="67" width="424" height="22" backcolor="#CCFFFF"/>
<textElement textAlignment="Right" verticalAlignment="Middle" markup="none">
<font size="10" isBold="true" pdfFontName="Helvetica-Bold" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[GRAFICO PARAMETRO]]></text>
</staticText>
<staticText>
<reportElement x="600" y="0" width="100" height="38"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Stampato in data]]></text>
</staticText>
<textField>
<reportElement x="700" y="0" width="102" height="38"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{today}]]></textFieldExpression>
</textField>
<image>
<reportElement x="0" y="0" width="100" height="67"/>
<imageExpression><![CDATA[$F{logo}]]></imageExpression>
</image>
<staticText>
<reportElement x="700" y="38" width="102" height="29"/>
<textElement textAlignment="Right"/>
<text><![CDATA[MaRe - Telecontrollo]]></text>
</staticText>
<textField>
<reportElement mode="Opaque" x="424" y="67" width="378" height="22" backcolor="#CCFFFF"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[' ' + $F{option}]]></textFieldExpression>
</textField>
</band>
</title>
<lastPageFooter>
<band height="387" splitType="Stretch">
<xyLineChart>
<chart evaluationTime="Page">
<reportElement x="0" y="0" width="802" height="387"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<xyDataset>
<dataset incrementType="Report"/>
<xySeries>
<seriesExpression><![CDATA["Unità " + $F{dsunita}]]></seriesExpression>
<xValueExpression><![CDATA[$F{day}]]></xValueExpression>
<yValueExpression><![CDATA[$F{valueNumber}]]></yValueExpression>
</xySeries>
</xyDataset>
<linePlot>
<plot/>
</linePlot>
</xyLineChart>
</band>
</lastPageFooter>
</jasperReport>
Datasource here is a JRBeanCollectionDataSource.

Putting it in the Detail band is wrong (as you noticed). Putting it in the Title or Summary will work. Your choice of evaluationTime="Page" doesn't look right. Try changing this to evaluationTime="Report"

Related

Too much white space around jasper subreport

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

How to split details across multiple columns while programmatically appending 'continuation' message for subsequent sections?

I have a customer request to split details of personal information (name, address, secondary addresses, etc) across multiple columns, if the dynamic size does not fit in the current column. As a caveat, the name field, followed by the word '(Continued)', is desired, as the title for the segments in subsequent columns.
Is this behavior possible with jasper-reports?
I have tried toggling an 'inBetween' flag with the beforeDetailEval() and afterDetailEval() hooks, checking that flag in the column header band, to optionally reprint the name + 'Continued', but the column header always calls the scriptlet method AFTER the afterDetailEval() method (does not make sense to my little mind), failing since the 'inBetween' flag is reset to false.
(Note: Detail band has been set with splitType to both 'Immediate' and 'Stretch', but neither approach has behaved as expected. The entire band just gets restarted at the beginning of the next column)
Is this possible, and if so, are there any suggestions for creative solutions for this scenario?
Also, there is strange behavior displaying where if a detail is split across multiple columns, the first part of the detail (up to the subreport element)is duplicated on the following column. This behavior is also undesirable to the customer, and needs to be adjusted so nothing (except the title) is duplicated.
This is the syntax desired by the customer:
Name 1 Name 2
Address 1 (Continued)
City 1 AL – Address 3
State 1 AL - City 3
Zip 1 AL - State 3
Additional Locations: AL - Zip 3
AL-Address 1 ...
AL-City 1
AL-State 1
AL-Zip 1
AL-Address 2
AL-City 2
AL-State 2
AL-Zip 2
Name 2
Address 2
City 2
State 2
Zip 2
Additional Locations:
AL-Address 1
AL – City 1
AL-State 1
AL – Zip 1
AL – Address 2
AL – City 2
AL – State 2
AL – Zip 2
This is what we are actually getting:
Name1 Name1
Address1 Address1
City1 City1
State1 State1
Zip1 Zip1
Additional Locations Additional Locations
AL-Name1 AL-City2
AL-Address1 AL-State2
AL-City1 AL-State2
AL-State1
AL-Zip1
AL-Name2
AL-Address2
This is a sample main jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2017-06-22T09:48:08 -->
<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="Blank_A4" columnCount="2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" scriptletClass="path.to.my.scriptlet" uuid="af53d807-7975-4ff7-bfc5-e438944aa795">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="Name" class="java.lang.String"/>
<field name="Address" class="java.lang.String"/>
<field name="City" class="java.lang.String"/>
<field name="State" class="java.lang.String"/>
<field name="Zip" class="java.lang.String"/>
<field name="AdditionalLocations" class="java.util.List"/>
<variable name="IN_MIDDLE_OF_DETAIL" class="java.lang.Boolean" calculation="System">
<initialValueExpression><![CDATA[Boolean.False]]></initialValueExpression>
</variable>
<columnHeader>
<band height="74" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="-10" y="0" width="100" height="30" uuid="258dce49-fb61-4887-bb30-69e80e96d8f1">
<printWhenExpression><![CDATA[$V{IN_MIDDLE_OF_DETAIL}]]></printWhenExpression>
</reportElement>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="-10" y="40" width="100" height="30" uuid="c18b2fab-900b-4641-aaef-2520510a3510">
<printWhenExpression><![CDATA[$V{IN_MIDDLE_OF_DETAIL}]]></printWhenExpression>
</reportElement>
<textFieldExpression><![CDATA["(CONTINUED)"]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="426" splitType="Stretch">
<textField>
<reportElement x="0" y="10" width="100" height="30" uuid="853a1b0d-a49e-45c4-8183-83cfd69bf5af"/>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="50" width="100" height="30" uuid="46697c6d-1c2f-422b-9170-6b2f36ce13ba"/>
<textFieldExpression><![CDATA[$F{Address}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="90" width="100" height="30" uuid="31730cd5-0b17-452e-8a22-d16ea2061605"/>
<textFieldExpression><![CDATA[$F{City}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="120" width="100" height="30" uuid="b4a4c671-dc63-41b4-b080-9ad5b750bb58"/>
<textFieldExpression><![CDATA[$F{State}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="160" width="100" height="30" uuid="8f8bec7c-3d4a-466b-8b02-2bb82e61904d"/>
<textFieldExpression><![CDATA[$F{Zip}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="0" y="220" width="100" height="110" uuid="8ef583fd-fa23-47d8-80d0-90de4f6478a0"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{AdditionalLocations})]]></dataSourceExpression>
<subreportExpression><![CDATA["Blank_A4_1.jasper"]]></subreportExpression>
</subreport>
<staticText>
<reportElement x="10" y="198" width="100" height="30" uuid="4887e0c1-3da2-4350-9454-4a3e33c0fe71"/>
<text><![CDATA[Additional Locations]]></text>
</staticText>
</band>
</detail>
</jasperReport>
This is the sample subreport jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2017-06-22T10:39:43 -->
<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="Blank_A4_1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9b8a1d93-2ee6-4d29-b9ec-7c56a3917729">
<queryString>
<![CDATA[]]>
</queryString>
<field name="Address" class="java.lang.String"/>
<field name="City" class="java.lang.String"/>
<field name="State" class="java.lang.String"/>
<field name="Zip" class="java.lang.String"/>
<detail>
<band height="168" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="0" y="10" width="100" height="30" uuid="3d74e624-6b6f-40e9-87d2-ddb5022668b2"/>
<textFieldExpression><![CDATA[$F{Address}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="50" width="100" height="30" uuid="5df31fa3-38ee-44a4-8931-e8eef45fb7a6"/>
<textFieldExpression><![CDATA[$F{City}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="89" width="100" height="30" uuid="964a282f-54c7-44a3-954d-27d1c70d3d0c"/>
<textFieldExpression><![CDATA[$F{State}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="130" width="100" height="30" uuid="e1349222-d945-4dec-8454-e2d6e3fb6a2a"/>
<textFieldExpression><![CDATA[$F{Zip}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
This is the basic scriptlet code to toggle the value of IN_MIDDLE_OF_DETAIL:
#Override
public void beforeDetailEval() throws JRScriptletException
{
setVariableValue("IN_MIDDLE_OF_DETAIL", Boolean.TRUE)
}
#Override
public void afterDetailEval() throws JRScriptletException
{
setVariableValue("IN_MIDDLE_OF_DETAIL", Boolean.FALSE)
}
Drop the scriptlet, there is no need for this, lets use the fact that subreport's has its own page count, hence when it breaks in main report it counts a page
The solution I would use is the pageHeader band in the subreport with a printWhenExpression on page number (>1).
Which means that the text that you like to display when subreport splits to new "page" (name and "Continue") goes into pageHeader of the subreport and should be printed on all subreport "pages" except the first one.
Since name does not seems to be part of the subreport datasource I will pass this as a parameter to the subreport.
Code in subreport to display header when page > 1
<pageHeader>
<band height="44">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}>1]]></printWhenExpression>
<textField>
<reportElement x="0" y="0" width="220" height="20" uuid="8cce4cab-6ccf-4ddb-b1f1-508dc97bfcfe"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="20" width="220" height="19" uuid="c18b2fab-900b-4641-aaef-2520510a3510"/>
<textElement verticalAlignment="Middle">
<font isItalic="true"/>
</textElement>
<textFieldExpression><![CDATA["(Continued)"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
Example output
I have cut down page height to reduce image
Full example
**main report jrxml**
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" columnCount="2" pageWidth="595" pageHeight="500" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="af53d807-7975-4ff7-bfc5-e438944aa795">
<queryString>
<![CDATA[]]>
</queryString>
<field name="name" class="java.lang.String"/>
<field name="address" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<field name="state" class="java.lang.String"/>
<field name="zip" class="java.lang.String"/>
<field name="additionalLocations" class="java.util.List"/>
<detail>
<band height="141" splitType="Immediate">
<textField isStretchWithOverflow="true">
<reportElement x="0" y="20" width="280" height="20" uuid="46697c6d-1c2f-422b-9170-6b2f36ce13ba">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="40" width="280" height="20" uuid="31730cd5-0b17-452e-8a22-d16ea2061605"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="60" width="280" height="20" uuid="b4a4c671-dc63-41b4-b080-9ad5b750bb58"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{state}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="80" width="280" height="20" uuid="8f8bec7c-3d4a-466b-8b02-2bb82e61904d"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{zip}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="0" y="120" width="280" height="20" isPrintWhenDetailOverflows="true" uuid="8ef583fd-fa23-47d8-80d0-90de4f6478a0"/>
<subreportParameter name="name">
<subreportParameterExpression><![CDATA[$F{name}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{additionalLocations})]]></dataSourceExpression>
<subreportExpression><![CDATA["C:/Users/pette/JaspersoftWorkspace/MyReports/SplitSubreport.jasper"]]></subreportExpression>
</subreport>
<staticText>
<reportElement x="0" y="100" width="280" height="20" uuid="4887e0c1-3da2-4350-9454-4a3e33c0fe71"/>
<textElement verticalAlignment="Middle">
<font isItalic="false" isUnderline="true"/>
</textElement>
<text><![CDATA[Additional Locations]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="280" height="20" uuid="258dce49-fb61-4887-bb30-69e80e96d8f1"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
**subreport jrxml**
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_1" pageWidth="280" pageHeight="200" columnWidth="280" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="9b8a1d93-2ee6-4d29-b9ec-7c56a3917729">
<parameter name="name" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="address" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<field name="state" class="java.lang.String"/>
<field name="zip" class="java.lang.String"/>
<pageHeader>
<band height="44">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}>1]]></printWhenExpression>
<textField>
<reportElement x="0" y="20" width="220" height="19" uuid="c18b2fab-900b-4641-aaef-2520510a3510"/>
<textElement verticalAlignment="Middle">
<font isItalic="true"/>
</textElement>
<textFieldExpression><![CDATA["(Continued)"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="220" height="20" uuid="8cce4cab-6ccf-4ddb-b1f1-508dc97bfcfe"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{name}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<detail>
<band height="85" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="-1" width="220" height="21" uuid="3d74e624-6b6f-40e9-87d2-ddb5022668b2"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="20" width="220" height="20" uuid="5df31fa3-38ee-44a4-8931-e8eef45fb7a6"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="40" width="220" height="20" uuid="964a282f-54c7-44a3-954d-27d1c70d3d0c"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{state}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="0" y="60" width="220" height="20" uuid="e1349222-d945-4dec-8454-e2d6e3fb6a2a"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{zip}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

Jasper reports - pagination issues

I am having the following issue with paging in Jasper Reports:
I have a report based on the results of a MySql query. Each page corresponds to one row returned from MySql. Basically the text field on the details page prints a long text or a clob.
I have added a page break at the end of the "details" section.
However:
If I use "split type" as "Immediate," the page break does not happen for any page that "overflows." In other words, if a text runs over over into two pages, the next record starts on page two itself instead of page three
If I use "split type" as "Prevent," an extra page break happens for all the records except for those that have very short text. The extra page causes several blank pages to be printed.
Needless to say, any help would be deeply appreciated!
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0 -->
<!-- 2017-03-18T17:00:56 -->
<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="TreatmentPlanNotes" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a6476bf3-e703-4b50-9368-2eec564bb444">
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<parameter name="beg_dt" class="java.util.Date"/>
<parameter name="end_dt" class="java.util.Date"/>
<parameter name="first_name" class="java.lang.String"/>
<parameter name="last_name" class="java.lang.String"/>
<field name="created_dt" class="java.sql.Timestamp"/>
<field name="note" class="java.lang.String"/>
<field name="patient" class="java.lang.Integer"/>
<field name="patient_name" class="java.lang.String"/>
<field name="doctor_name" class="java.lang.String"/>
<group name="Group1" isStartNewPage="true">
<groupExpression><![CDATA[$V{REPORT_COUNT}]]></groupExpression>
<groupHeader>
<band/>
</groupHeader>
<groupFooter>
<band/>
</groupFooter>
</group>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="57" splitType="Stretch">
<staticText>
<reportElement x="14" y="10" width="184" height="30" forecolor="#3D0D0C" uuid="a847deeb-9517-4108-bb2b-9761158446cf"/>
<textElement>
<font fontName="Adobe Garamond Pro Bold" size="20"/>
</textElement>
<text><![CDATA[Treatment Plans:]]></text>
</staticText>
<textField>
<reportElement x="185" y="10" width="125" height="30" forecolor="#3D0A08" uuid="bee361db-d322-4d7c-85b9-22c3490ca018">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement>
<font fontName="Adobe Garamond Pro Bold" size="20"/>
</textElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("MM/dd/yyyy").format($P{beg_dt})]]></textFieldExpression>
</textField>
<textField>
<reportElement x="374" y="10" width="129" height="30" forecolor="#3D0A08" uuid="00abf204-6e5d-4c42-ad41-21fc3eb40247">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement>
<font fontName="Adobe Garamond Pro Bold" size="20"/>
</textElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("MM/dd/yyyy").format($P{end_dt})]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="320" y="10" width="30" height="30" forecolor="#3D0A08" uuid="a602d6a4-51ea-47f1-aceb-4a5dcc4ae88d"/>
<textElement>
<font fontName="Adobe Garamond Pro Bold" size="20"/>
</textElement>
<text><![CDATA[to]]></text>
</staticText>
</band>
</title>
<detail>
<band height="250" splitType="Immediate">
<textField>
<reportElement x="4" y="8" width="106" height="24" uuid="f78e49a7-3d65-4a68-9dec-b4708a06db72"/>
<textElement>
<font fontName="Adobe Garamond Pro Bold" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{created_dt}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="128" y="9" width="112" height="24" uuid="2cfbfba2-e429-415c-8737-05282649b74e"/>
<textElement>
<font fontName="Adobe Garamond Pro Bold" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{patient_name}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="2" y="43" width="550" height="207" isRemoveLineWhenBlank="true" uuid="f15bcb7e-b3d1-4f61-a2ae-63e4807c8a5a"/>
<textFieldExpression><![CDATA[ITreatUtils.convertHTMLtoPlain($F{note})]]></textFieldExpression>
</textField>
</band>
</detail>
<pageFooter>
<band height="37" splitType="Stretch">
<textField>
<reportElement x="229" y="5" width="100" height="30" isRemoveLineWhenBlank="true" uuid="c19b6d54-120d-449d-a138-f1e6b91641da"/>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
</jasperReport>

iReport - Limit number of records allowed in a sub report

I am trying to create a report that will be used for check printing. Its layout is stub, stub, and then check. I thought the best way to do this would be have the detail for the stubs be a sub-report (inserted twice on the report) and the normal detail of the report for the check info. A 3rd party device will handle the "check" base on the info I pass in on the report in that detail band (printing account info for the micr part of the check, adding a signature and some anti theft "stuff").
The problem is I can't figure out how to limit the number of records on the sub-report. I have tried setting the height in the master for the band, in the master for the sub-report property, and on the sub-report for the height of the report. Nothing seemed to work. I also tried to do something like.
($V{REPORT_COUNT} %15) == 0
Now I am not a Java guy. We use jasper reports for form generation in or python based ERP system.
Any suggestions on how I should go about designing this report? Also to note the "check" part of the report would need to have void details on all pages except one.
Edit
For example, lets say that we pay vendor FOO for 35 invoices. The layout is going to be stub, stub, check (each a 1/3rd the size of the page). Stub 1 and stub 2 are identical copies of each other. So page one would show 15 invoices in stub one and then show the the SAME 15 invoices in the next stub, and then it would print the physical check details on the bottom 3rd of the page. Page 2 would show the next 15 invoices (same layout as above) but the check details are VOIDED. The last page will show the remaining 5 invoices.
The pages are perforated. We keep 1 stub, and then send the check stub to the vendor.
jrxml of master report
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="ap_checks" language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="3fb75d91-5293-4c89-8450-938a5ac37235">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["/Users/pkraus/iReport/"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select
appay.id, appay.batch_id, appay.date, appay.payment_type_id, appay.vendor_id,appay.total,
appay.check_number,
vendors.code as vendor_code,vendors.name as vendor_name,
locations.name,locations.address_one,locations.address_two,locations.city,
states.code as state_code,locations.zip_code
from
ap_payments as appay,
ap_payment_types,
vendors,
locations,
states
where
appay.payment_type_id = ap_payment_types.id and
ap_payment_types.print_check = 't' and
vendors.id = appay.vendor_id and
locations.id = vendors.remit_to_id and
states.id = locations.state_id]]>
</queryString>
<field name="id" class="java.lang.Integer"/>
<field name="batch_id" class="java.lang.Integer"/>
<field name="date" class="java.sql.Date"/>
<field name="payment_type_id" class="java.lang.Integer"/>
<field name="vendor_id" class="java.lang.Integer"/>
<field name="total" class="java.math.BigDecimal"/>
<field name="check_number" class="java.lang.String"/>
<field name="vendor_code" class="java.lang.String"/>
<field name="vendor_name" class="java.lang.String"/>
<field name="name" class="java.lang.String"/>
<field name="address_one" class="java.lang.String"/>
<field name="address_two" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<field name="state_code" class="java.lang.String"/>
<field name="zip_code" class="java.lang.String"/>
<detail>
<band height="200" splitType="Stretch">
<subreport isUsingCache="true" runToBottom="false">
<reportElement uuid="71baa8ec-c623-4032-a2b0-381776857ee6" x="0" y="0" width="572" height="152"/>
<subreportParameter name="check_id">
<subreportParameterExpression><![CDATA[$F{id}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "ap_checks_stub.jasper"]]></subreportExpression>
</subreport>
</band>
<band height="178"/>
<band height="163">
<textField>
<reportElement uuid="00182356-2626-4e23-90bf-c8ab35d9bd11" x="380" y="54" width="56" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{date}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="042dac2b-6fb5-401d-ab90-11c60cecfa98" x="17" y="114" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{address_one}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="ec25e5af-5b4d-4f5a-8197-62a84e0b5773" x="17" y="125" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{address_two}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="37d3f097-e308-4601-9e1e-e21be81ad57a" x="17" y="134" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="9df87896-ea75-4411-aeb6-db0b1484d219" x="178" y="134" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{zip_code}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="d99d514e-893b-4b45-ae2b-b8677cee6ed9" x="98" y="134" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{state_code}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="926d835e-adc4-4f4b-a29f-5fa18d45090c" x="17" y="74" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{vendor_code}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="6a8349b5-c86a-4ffc-87b7-84000ebef6af" x="17" y="105" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{vendor_name}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="ed874ea2-a95d-47cd-bf8e-b2b559a5dbbf" x="472" y="54" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{check_number}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
jrxml of sub 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="ap_checks_stub" language="groovy" pageWidth="572" pageHeight="100" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="31589b1a-6d6a-40ff-870b-e84e52104956">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="check_id" class="java.lang.Number"/>
<queryString>
<![CDATA[select
pi.id as payment_id, pi.payment,
vi.number,vi.date,
ap_payments.check_number, vendors.code
from
payment_invoices as pi,
vendor_invoices as vi,
ap_payments,
vendors
where
vi.id = pi.invoice_id and
ap_payments.id = pi.check_id and
ap_payments.vendor_id = vendors.id and
pi.check_id = 1]]>
</queryString>
<field name="payment_id" class="java.lang.Integer"/>
<field name="payment" class="java.math.BigDecimal"/>
<field name="number" class="java.lang.String"/>
<field name="date" class="java.sql.Date"/>
<field name="check_number" class="java.lang.String"/>
<field name="code" class="java.lang.String"/>
<columnHeader>
<band height="24" splitType="Stretch">
<staticText>
<reportElement uuid="424923c4-ac9f-4763-919e-afe81870fb6f" x="0" y="0" width="100" height="20"/>
<textElement/>
<text><![CDATA[number]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="28" splitType="Stretch">
<textField>
<reportElement uuid="4b06f8cf-15d3-44a3-9edf-31e5f760fac6" x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{number}]]></textFieldExpression>
</textField>
<break>
<reportElement uuid="278dc135-0e6b-4d47-84bc-b3bf79c90edf" x="0" y="20" width="100" height="1">
<printWhenExpression><![CDATA[$V{REPORT_COUNT} <= 15]]></printWhenExpression>
</reportElement>
</break>
<textField>
<reportElement uuid="80635d70-845f-4893-9f42-f13a064a255d" x="298" y="8" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
</band>
</detail>
<pageFooter>
<band height="24" splitType="Stretch">
<textField>
<reportElement uuid="bc3035b9-7989-46a4-abf6-ff10ec486a60" x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{code}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<lastPageFooter>
<band height="24">
<textField>
<reportElement uuid="3d6e71b0-7fb7-40ec-9e04-529f39003e71" x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{code}]]></textFieldExpression>
</textField>
</band>
</lastPageFooter>
</jasperReport>
Try
$V{REPORT_COUNT} == 15+(($V{PAGE_NUMBER}-1)*15)
in the Print When Expression of the break in the subreport detail band.

JasperReports' iReport - generating a grand total

I have a variable datatype set up in the group footer band that generates a subtotal for the counts in each group in my report. Works great.
I would like a grand total to generate on the last page of my report, simply summing up the subtotal values. This has been harder to figure out.
Any suggestions?
You can use two variables with different resetType - for calculating sum in group (with resetType="Group" resetGroup="groupName" calculation="Sum" properties) and for calculating total sum for whole report (with resetType="Report" calculation="Sum" properties).
The sample (jrxml file):
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="grand_total_sample" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString>
<![CDATA[SELECT DOCUMENTID, POSITIONNO, PRODUCTID, QUANTITY FROM POSITIONS WHERE PRODUCTID < 10 AND POSITIONNO > 18 ORDER BY POSITIONNO]]>
</queryString>
<field name="DOCUMENTID" class="java.lang.Integer"/>
<field name="POSITIONNO" class="java.lang.Integer"/>
<field name="PRODUCTID" class="java.lang.Integer"/>
<field name="QUANTITY" class="java.lang.Integer"/>
<variable name="quantitySumInGroup" class="java.lang.Integer" resetType="Group" resetGroup="positionNoGroup" calculation="Sum">
<variableExpression><![CDATA[$F{QUANTITY}]]></variableExpression>
<initialValueExpression><![CDATA[0]]></initialValueExpression>
</variable>
<variable name="quantityTotalSum" class="java.lang.Integer" calculation="Sum">
<variableExpression><![CDATA[$F{QUANTITY}]]></variableExpression>
<initialValueExpression><![CDATA[0]]></initialValueExpression>
</variable>
<group name="positionNoGroup">
<groupExpression><![CDATA[$F{POSITIONNO}]]></groupExpression>
<groupHeader>
<band height="20">
<textField>
<reportElement x="0" y="0" width="400" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center">
<font isBold="true" isItalic="true" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA["Position no: " + $F{POSITIONNO}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
<groupFooter>
<band height="20">
<textField>
<reportElement x="0" y="0" width="400" height="20"/>
<textElement>
<font isBold="false" isItalic="true" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA["Sum in group: " + $V{quantitySumInGroup}]]></textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{DOCUMENTID}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{PRODUCTID}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="200" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{QUANTITY}]]></textFieldExpression>
</textField>
</band>
</detail>
<lastPageFooter>
<band height="20">
<textField>
<reportElement x="0" y="0" width="400" height="20"/>
<textElement>
<font isBold="true" isItalic="true" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA["Total sum: " + $V{quantityTotalSum}]]></textFieldExpression>
</textField>
</band>
</lastPageFooter>
</jasperReport>
The result will be:
Just create a new variable and in the variable expression add up all of the subtotals using their variable name
for instance:
$V{subtotal1}+$V{subtotal2}+$V{subtotal3}
After that, throw it in the 'summary' band and in the report properties check the box that says "summary on new page". That way it'll be on the last page of your report.