Using Table component: How to avoid displaying multiple copies of same data - jasper-reports

The iReport is generating multiple (identical) tables for the query I am submitting.
I am trying to extract all data from the manga DB table into a Table component. I successfully does so but is creating multiple tables with the same data.
<?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="mangaReport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="43bb2d5b-ad44-48ca-bcc9-bec319a36466">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="New Dataset 1" uuid="820ac89b-615e-453d-9593-9deeb8c44a87">
<queryString language="SQL">
<![CDATA[select * from manga]]>
</queryString>
<field name="name" class="java.lang.String"/>
<field name="author" class="java.lang.String"/>
</subDataset>
<queryString language="SQL">
<![CDATA[select * from manga]]>
</queryString>
<field name="name" class="java.lang.String"/>
<field name="author" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="39" splitType="Stretch"/>
</title>
<pageHeader>
<band height="18" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="31" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<componentElement>
<reportElement uuid="4f76c19e-e304-45b3-a521-b30aa4ecb03e" key="table 1" style="table 1" x="185" y="34" width="360" height="50"/>
<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="New Dataset 1" uuid="9f479053-64b3-49a7-a986-2415ac20385f">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column uuid="5b10c367-6de0-4799-8408-ad8c7dadd888" width="90">
<jr:columnHeader style="table 1_CH" height="30">
<staticText>
<reportElement uuid="7470c697-d500-46e0-88c1-d42883576ef1" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20">
<textField>
<reportElement uuid="32a30162-dca0-4bda-8ef2-ae8f41d4340a" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="3f6fac9d-5a87-4fee-ac81-51170b6d7481" width="90">
<jr:columnHeader style="table 1_CH" height="30">
<staticText>
<reportElement uuid="21335524-5b94-464b-83fc-36d7734596e4" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[author]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20">
<textField>
<reportElement uuid="9765da67-b578-4bc3-b0f4-5878c64b9e66" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{author}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
I tried to search the forums but couldn't find the solution.
Please advice

The reason of this issue that JR engine iterates the table twice - first time using the main datasource (report's datasource) with Detail band and the second time with Table component's datasource.
You can delete the main datasource and put the Table component to the Summary band, for example.
In this case your template will be like this:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport .. whenNoDataType="AllSectionsNoDetail" ..>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="New Dataset 1" uuid="820ac89b-615e-453d-9593-9deeb8c44a87">
<queryString language="SQL">
<![CDATA[select name, author from address]]>
</queryString>
<field name="name" class="java.lang.String"/>
<field name="author" class="java.lang.String"/>
</subDataset>
<title>
<band height="39" splitType="Stretch"/>
</title>
<detail>
<band height="125" splitType="Stretch"/>
</detail>
<summary>
<band height="63" splitType="Stretch">
<componentElement>
<reportElement uuid="4f76c19e-e304-45b3-a521-b30aa4ecb03e" key="table 1" style="table 1" x="131" y="0" width="360" height="50"/>
<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="New Dataset 1" uuid="9f479053-64b3-49a7-a986-2415ac20385f">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column uuid="5b10c367-6de0-4799-8408-ad8c7dadd888" width="90">
<jr:columnHeader style="table 1_CH" height="30">
<staticText>
<reportElement uuid="7470c697-d500-46e0-88c1-d42883576ef1" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20">
<textField>
<reportElement uuid="32a30162-dca0-4bda-8ef2-ae8f41d4340a" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="3f6fac9d-5a87-4fee-ac81-51170b6d7481" width="90">
<jr:columnHeader style="table 1_CH" height="30">
<staticText>
<reportElement uuid="21335524-5b94-464b-83fc-36d7734596e4" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[author]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20">
<textField>
<reportElement uuid="9765da67-b578-4bc3-b0f4-5878c64b9e66" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{author}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</summary>
</jasperReport>
Do not forget to set whenNoDataType report's property as AllSectionsNoDetail in this case - to avoid the hiding Summary band.
Another way - you can remove Table component and use Detail band.
In this case the template will be like this:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ...>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<queryString language="SQL">
<![CDATA[select name, author from address]]>
</queryString>
<field name="name" class="java.lang.String"/>
<field name="author" class="java.lang.String"/>
<title>
<band height="39" splitType="Stretch"/>
</title>
<columnHeader>
<band height="30">
<staticText>
<reportElement uuid="21335524-5b94-464b-83fc-36d7734596e4" style="table 1_CH" x="90" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[author]]></text>
</staticText>
<staticText>
<reportElement uuid="7470c697-d500-46e0-88c1-d42883576ef1" style="table 1_CH" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[name]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="9765da67-b578-4bc3-b0f4-5878c64b9e66" style="table 1_TD" x="90" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="32a30162-dca0-4bda-8ef2-ae8f41d4340a" style="table 1_TD" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{author}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

Related

How to introduce the page break after pre-defined number of rows in the jr:table component?

I am using jasper report version 6.1 and wanted page break after pre-defined number of rows in the jr:table component. I have also tried doing the same in version 5 and it works fine but in version 6+ I am not able to do it.
Sharing the links which I followed if any one have other solution please let me know.
http://community.jaspersoft.com/wiki/ireport-how-introduce-page-break-after-pre-defined-number-rows-table-component
http://community.jaspersoft.com/questions/845487/inserting-break-table-print-only-10-rows-page-jasper-reports-372
This is what I have tried:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 6.1.0 -->
<!-- 2017-05-29T15:29:33 -->
<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_4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="957c1fea-8994-4195-9d7a-2bbf0baf7180">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Max apex"/>
<style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Dataset1" uuid="435d51b0-6d3e-442e-9a96-ae7412b12278">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Max apex"/>
<queryString>
<![CDATA[select * from dept]]>
</queryString>
<field name="DEPTNO" class="java.math.BigDecimal"/>
<field name="DNAME" class="java.lang.String"/>
<field name="LOC" class="java.lang.String"/>
<group name="DEPTNO">
<groupExpression><![CDATA[$F{DEPTNO}]]></groupExpression>
</group>
<group name="DNAME">
<groupExpression><![CDATA[$F{DNAME}]]></groupExpression>
</group>
<group name="LOC">
<groupExpression><![CDATA[$F{LOC}]]></groupExpression>
</group>
</subDataset>
<queryString>
<![CDATA[select * from dept]]>
</queryString>
<field name="DEPTNO" class="java.math.BigDecimal"/>
<field name="DNAME" class="java.lang.String"/>
<field name="LOC" class="java.lang.String"/>
<group name="DEPTNO">
<groupExpression><![CDATA[$F{DEPTNO}]]></groupExpression>
</group>
<group name="DNAME">
<groupExpression><![CDATA[$F{DNAME}]]></groupExpression>
</group>
<group name="LOC">
<groupExpression><![CDATA[$F{LOC}]]></groupExpression>
</group>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="145" splitType="Stretch">
<componentElement>
<reportElement positionType="FixRelativeToBottom" x="10" y="0" width="500" height="110" uuid="b37c89ae-600a-4fb8-ac64-e142bfe22e13"/>
<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" uuid="8f84378b-9508-4763-8265-69e68c41febe">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="100" uuid="00a00921-f5fa-4352-924c-f0531c919f71">
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="100" height="30" uuid="d88580f8-05d2-4eb0-a098-00e877c58c39"/>
<text><![CDATA[DEPTNO]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="90" height="30" uuid="15fda94a-b686-4808-b55c-3e08a8e86187"/>
<textFieldExpression><![CDATA[$F{DEPTNO}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="140" uuid="72e58aec-00f1-4937-8600-b32a6010d4d6">
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="130" height="30" uuid="942c89ca-e914-4809-bb18-3b7065b413f7"/>
<text><![CDATA[DNAME]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="130" height="30" uuid="8b936e63-5f84-4fd7-b21c-8c08fb9550a5"/>
<textFieldExpression><![CDATA[$F{DNAME}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="140" uuid="f312cbac-4554-492c-928f-dd84b5a55d42">
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="120" height="30" uuid="ce385917-88aa-4e51-9cae-a7a142f78323"/>
<text><![CDATA[LOC]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="120" height="30" uuid="0e43f425-558c-4001-9c44-ca14798bcb75"/>
<textFieldExpression><![CDATA[$F{LOC}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
The solution to use a a group expression inside the subdatset works perfectly fine also in jasper reports v6+.
Example (built from code and data from this answer)
Adding groupExpression to the subDataset to break to new page every 2 records ($V{REPORT_COUNT}-1)/2)
<subDataset name="tableDataset" uuid="7a53770f-0350-4a73-bfc1-48a5f6386594">
<field name="User" class="java.lang.String"/>
<field name="Rep" class="java.math.BigDecimal"/>
<group name="pageBreakGroup" isStartNewPage="true">
<groupExpression><![CDATA[(int)(($V{REPORT_COUNT}-1)/2)]]></groupExpression>
</group>
</subDataset>
Expand code snippet for full 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="reputation" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a88bd694-4f90-41fc-84d0-002b90b2d73e">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="CVS"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="tableDataset" uuid="7a53770f-0350-4a73-bfc1-48a5f6386594">
<field name="User" class="java.lang.String"/>
<field name="Rep" class="java.math.BigDecimal"/>
<group name="pageBreakGroup" isStartNewPage="true">
<groupExpression><![CDATA[(int)(($V{REPORT_COUNT}-1)/2d)]]></groupExpression>
</group>
</subDataset>
<parameter name="displayRecordNumber" class="java.lang.Boolean">
<defaultValueExpression><![CDATA[true]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<title>
<band height="50">
<componentElement>
<reportElement key="table" style="table" x="0" y="0" width="555" height="47" uuid="76ab08c6-e757-4785-a43d-b65ad4ab1dd5"/>
<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="tableDataset" uuid="07e5f1c2-af7f-4373-b653-c127c47c9fa4">
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
</datasetRun>
<jr:column width="90" uuid="918270fe-25c8-4a9b-a872-91299cddbc31">
<printWhenExpression><![CDATA[$P{displayRecordNumber}]]></printWhenExpression>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="5cd6da41-01d5-4f74-99c2-06784f891d1e"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Record number]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="30" uuid="5fe48359-0e7e-44b2-93ac-f55404189832"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="7979d8a2-4e3c-42a7-9ff9-86f8e0b164bc">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="61d5f1b6-7677-4511-a10c-1fb8a56a4b2a"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Username]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="30" uuid="a3cdb99d-3bf6-4c66-b50c-259b9aabfaef"/>
<box leftPadding="3" rightPadding="3"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{User}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="625e4e5e-5057-4eab-b4a9-c5b22844d25c">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="e1c07cb8-a44c-4a8d-8566-5c86d6671282"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Reputation]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="30" rowSpan="1">
<textField pattern="#,##0">
<reportElement x="0" y="0" width="90" height="30" uuid="6be2d79f-be82-4c7b-afd9-0039fb8b3189"/>
<box leftPadding="3" rightPadding="3"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{Rep}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</title>
</jasperReport>
Result in JasperStudio version 6.2
As you can see 3 pages (2 records on each, total record count 5).

Jasper - first page in blank

I'm inserting a table in my detail band, but if the value is too long in my textfield, the value is showed only in the second page and because of this the first page is blank.
How I can avoid empty first page on Ireport?
Below is my XML 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="RelatorioLicenca" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="089efa24-5b40-467a-b66a-053b77756f0c">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="table">
<box>
<pen lineWidth="0.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="dataset1" uuid="7664203f-829d-4951-8151-f0c3630108d3"/>
<subDataset name="dataset2" uuid="b05d44f7-3dfe-4fb8-9014-34c037e8bc28"/>
<subDataset name="dataset3" uuid="f3336d08-b905-45da-9cd2-871a08fbb704"/>
<subDataset name="dataset4" uuid="8a31051f-53a0-4438-8f36-655294512ecb"/>
<subDataset name="itemDataSet" uuid="07d68903-44a5-4148-9f4e-46a764459558">
<field name="html" class="java.lang.String"/>
</subDataset>
<parameter name="LOGO_IMAGE" class="java.io.InputStream"/>
<parameter name="BARRA_IMAGE" class="java.io.InputStream"/>
<parameter name="listCriterioQci" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="73" splitType="Stretch">
<image>
<reportElement x="137" y="2" width="284" height="54" uuid="07b821b9-797c-439c-92e8-1963c63ee2ae"/>
<imageExpression><![CDATA[$P{LOGO_IMAGE}]]></imageExpression>
</image>
<image>
<reportElement x="0" y="59" width="555" height="14" uuid="4b071978-b491-4bdb-b964-77cc3e378966"/>
<imageExpression><![CDATA[$P{BARRA_IMAGE}]]></imageExpression>
</image>
</band>
</title>
<detail>
<band height="218" splitType="Stretch">
<componentElement>
<reportElement key="table" style="table" positionType="Float" isPrintRepeatedValues="false" mode="Opaque" x="2" y="8" width="553" height="197" isPrintWhenDetailOverflows="true" forecolor="#FFFFFF" uuid="086200b3-e8f8-454d-84ef-d91dbe233d92"/>
<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="itemDataSet" uuid="376ddebe-37e7-49e4-9a3c-c12cdb054808">
<dataSourceExpression><![CDATA[$P{listCriterioQci}]]></dataSourceExpression>
</datasetRun>
<jr:column width="554" uuid="cc022176-90eb-4639-8818-85293cb2da05">
<jr:detailCell style="table" height="135" rowSpan="1">
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="31" width="554" height="92" isPrintWhenDetailOverflows="true" uuid="75438790-5295-4508-b6fe-cae1b962ae1d"/>
<box>
<pen lineStyle="Solid" lineColor="#FFFFFF"/>
<topPen lineStyle="Solid" lineColor="#FFFFFF"/>
<leftPen lineStyle="Solid" lineColor="#FFFFFF"/>
<bottomPen lineStyle="Solid" lineColor="#FFFFFF"/>
<rightPen lineStyle="Solid" lineColor="#FFFFFF"/>
</box>
<textElement markup="html"/>
<textFieldExpression><![CDATA[$F{html}]]></textFieldExpression>
</textField>
<line>
<reportElement positionType="Float" x="0" y="15" width="554" height="1" uuid="7a8ae78a-41c3-4612-aeff-4aa9bbfe74f5">
<printWhenExpression><![CDATA[new Boolean($F{html} != null)]]></printWhenExpression>
</reportElement>
</line>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<pageFooter>
<band height="21" splitType="Stretch">
<textField>
<reportElement mode="Opaque" x="342" y="4" width="170" height="13" uuid="26decbd6-15dd-4f66-99d7-132b5b54a889"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement mode="Opaque" x="514" y="4" width="40" height="13" uuid="e34184f8-e277-4ec3-9a69-0c07d0729e25"/>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement x="1" y="4" width="211" height="13" uuid="68ea646b-0cef-4427-86b7-32f0f5bd47f8"/>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="5" splitType="Stretch"/>
</summary>
</jasperReport>

Crosstab applying calculated functions by default

I have a crosstab made out of the dataset as follows
I expect no calculation function on the measure columns. But, the report when it runs always takes the highest by default and the result looks as below. How do I get the report to just give the pivoted data and not perform any calculation on the measures?
I expect the data to look as shown in the picture below
Please find below the related 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="crosstabmeasure" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e47b3f7d-1e00-4702-a900-be50a229f085">
<import value="org.apache.commons.lang3.time.*"/>
<import value="java.util.Date"/>
<style name="Crosstab_CH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CG" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CT" mode="Opaque" backcolor="#005FB3">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="set1" uuid="0271cb46-f184-47b2-8ab3-e6ee96ea33ef">
<parameter name="Locale" class="java.lang.String"/>
<parameter name="UtcOffSet" class="java.lang.Integer"/>
<queryString>
<![CDATA[select #curRank := #curRank + 1 AS rank, inter.*
from internatioinlization inter, (SELECT #curRank := 0) r
where 1 = case when 1 = 1 and $P{Locale} is not null and $P{UtcOffSet} is not null then 1 else 0 end]]>
</queryString>
<field name="rank" class="java.lang.Double"/>
<field name="col1" class="java.lang.String"/>
<field name="col2" class="java.lang.Integer"/>
<field name="col3" class="java.sql.Timestamp"/>
<field name="col4" class="java.lang.String"/>
</subDataset>
<parameter name="Locale" class="java.lang.String"/>
<parameter name="UtcOffSet" class="java.lang.Integer"/>
<queryString>
<![CDATA[select #curRank := #curRank + 1 AS rank, inter.*
from internatioinlization inter, (SELECT #curRank := 0) r
where 1 = case when 1 = 1 and $P{Locale} is not null and $P{UtcOffSet} is not null then 1 else 0 end]]>
</queryString>
<field name="rank" class="java.lang.Double"/>
<field name="col1" class="java.lang.String"/>
<field name="col2" class="java.lang.Integer"/>
<field name="col3" class="java.sql.Timestamp"/>
<field name="col4" class="java.lang.String"/>
<summary>
<band height="211" splitType="Stretch">
<crosstab>
<reportElement x="0" y="0" width="555" height="211" uuid="6c5ccb8a-50fc-4158-b2ba-88d864aa1e43">
</reportElement>
<crosstabParameter name="Locale">
<parameterValueExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}.get("Locale")]]></parameterValueExpression>
</crosstabParameter>
<crosstabParameter name="UtcOffSet" class="java.lang.Integer">
<parameterValueExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}.get("UtcOffSet")]]></parameterValueExpression>
</crosstabParameter>
<crosstabDataset>
<dataset>
<datasetRun subDataset="set1" uuid="d255c9b9-fbb2-420a-8ef5-3236098654f1">
<datasetParameter name="Locale">
<datasetParameterExpression><![CDATA[$P{Locale}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="UtcOffSet">
<datasetParameterExpression><![CDATA[$P{UtcOffSet}]]></datasetParameterExpression>
</datasetParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
</dataset>
</crosstabDataset>
<rowGroup name="col11" width="60">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{col1}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="86c09a7f-46b5-4d2f-ba87-715f99d832a8"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{col11}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents>
<staticText>
<reportElement x="0" y="0" width="-2147483648" height="-2147483648" uuid="94fca0ea-1572-4d42-85d9-b06f92c73b6e"/>
<text><![CDATA[Total col11]]></text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<columnGroup name="col41" height="20">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{col4}]]></bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="120" height="20" uuid="137ef406-6a2e-4629-9d38-4858c4a5ae2c"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{col41}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents>
<staticText>
<reportElement x="0" y="0" width="-2147483648" height="-2147483648" uuid="5c71211d-f1db-4911-8923-2bdb208ddb99"/>
<text><![CDATA[Total col41]]></text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<measure name="col2_MEASURE1" class="java.lang.Integer">
<measureExpression><![CDATA[$F{col2}]]></measureExpression>
</measure>
<measure name="col3_MEASURE1" class="java.sql.Timestamp">
<measureExpression><![CDATA[$F{col3}]]></measureExpression>
</measure>
<crosstabCell width="120" height="20">
<cellContents mode="Opaque" style="Crosstab_CD">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="861d0d3a-d774-4b0c-ae7d-ace315bf305c"/>
<box>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{col2_MEASURE1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="60" y="0" width="60" height="20" uuid="163ed502-e753-444a-942d-832d84da0a5f"/>
<box>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{col3_MEASURE1} != null ? DateFormat.getDateInstance(DateFormat.SHORT, new Locale($P{Locale}.split("-")[0], $P{Locale}.split("-")[1])).format(DateUtils.addMinutes($V{col3_MEASURE1},$P{UtcOffSet})) : null]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" columnTotalGroup="col41">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="10" forecolor="#FFFFFF" uuid="2576b9e2-3bba-40e3-aa15-5f4f0aada549"/>
<textFieldExpression><![CDATA[$V{col2_MEASURE1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="10" width="60" height="10" forecolor="#FFFFFF" uuid="a111181f-b60f-4afd-8292-9e260c1b9ce2"/>
<textFieldExpression><![CDATA[$V{col3_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="col11">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="10" forecolor="#FFFFFF" uuid="9adf6c9c-acee-4673-8b70-a376e7d1cbb4"/>
<textFieldExpression><![CDATA[$V{col2_MEASURE1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="10" width="60" height="10" forecolor="#FFFFFF" uuid="9baedeed-4770-4153-b639-afc0965e9467"/>
<textFieldExpression><![CDATA[$V{col3_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="col11" columnTotalGroup="col41">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="10" forecolor="#FFFFFF" uuid="a2805e0a-080d-42be-ad86-a7e8e666f571"/>
<textFieldExpression><![CDATA[$V{col2_MEASURE1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="10" width="60" height="10" forecolor="#FFFFFF" uuid="c485f69d-91e1-4b19-a8ab-bdbfa3cafcc6"/>
<textFieldExpression><![CDATA[$V{col3_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
</crosstab>
</band>
</summary>
</jasperReport>
If you want to prevent bucketing/aggregation for the col1 row group, you can add a second row group (with no header cells) that has distinct values for each record. For instance:
<rowGroup name="RecNo" width="0">
<bucket class="java.lang.Integer">
<bucketExpression>$V{REPORT_COUNT}</bucketExpression>
</bucket>
</rowGroup>

iReport: Getting multiple copies of table in detail band

I am new at iReport. So I want to make a simple report based on data.
My problem is when my rows are less then detail band's size the whole table gets repeated in detail band, and I dont want it again. If my rows are aproximately 5, then same table gets copied 4 times in detail band, and not only table but each and every thing I put in detail band. It gets repeated itself till detail band limits come.
So am I making some mistake, or I have to set some property of detail band in iReport?
please help me friends. Thanks in advance.
This is the generated result:
Here is my code of jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport language="groovy" bottomMargin="20" topMargin="20" rightMargin="20" leftMargin="20" columnWidth="555"
whenNoDataType="AllSectionsNoDetail" pageHeight="842" pageWidth="595" name="test"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jasperreports.sourceforge.net/jasperreports">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="table">
<box>
<pen lineColor="#000000" lineWidth="1.0"/>
</box>
</style>
<style name="table_TH" backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table_CH" backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table_TD" backcolor="#FFFFFF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 1">
<box>
<pen lineColor="#000000" lineWidth="1.0"/>
</box>
</style>
<style name="table 1_TH" backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 1_CH" backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 1_TD" backcolor="#FFFFFF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 2">
<box>
<pen lineColor="#000000" lineWidth="1.0"/>
</box>
</style>
<style name="table 2_TH" backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 2_CH" backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 2_TD" backcolor="#FFFFFF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 3">
<box>
<pen lineColor="#000000" lineWidth="1.0"/>
</box>
</style>
<style name="table 3_TH" backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 3_CH" backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 3_TD" backcolor="#FFFFFF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 4">
<box>
<pen lineColor="#000000" lineWidth="1.0"/>
</box>
</style>
<style name="table 4_TH" backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 4_CH" backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 4_TD" backcolor="#FFFFFF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 5">
<box>
<pen lineColor="#000000" lineWidth="1.0"/>
</box>
</style>
<style name="table 5_TH" backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 5_CH" backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<style name="table 5_TD" backcolor="#FFFFFF" mode="Opaque">
<box>
<pen lineColor="#000000" lineWidth="0.5"/>
</box>
</style>
<subDataset name="a">
<parameter name="sem" class="java.lang.String">
<defaultValueExpression>
<![CDATA[]]>
</defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select final."M" as "ENROLLMENT",sem_batch.sem,sem_batch.batch,final."N" as "TTL_WKDY",final."O" as "PRESENT",round(((100*"O")/"N"),2) as "PERCENTAGE" from sem_batch, (select m."Std_id" as "M",l."Batch" as "L",l."Btch" as "N",m."Std" as "O" from (select count(b.batch_id) as "Btch",b.batch_id as "Batch" from batch_wkday b where b.batch_id like $P{sem} group by batch_id) l, (select count(a.std_id) as "Std",a.std_id as "Std_id",s.batch_id as "Batch" from attendance a,student_detail s where a.std_id=s.std_id and s.batch_id like $P{sem} group by a.std_id,s.batch_id) m where l."Batch"=m."Batch") final where final."L"=sem_batch.batch_id]]>
</queryString>
<field name="ENROLLMENT" class="java.math.BigDecimal"/>
<field name="SEM" class="java.math.BigDecimal"/>
<field name="BATCH" class="java.lang.String"/>
<field name="TTL_WKDY" class="java.math.BigDecimal"/>
<field name="PRESENT" class="java.math.BigDecimal"/>
<field name="PERCENTAGE" class="java.math.BigDecimal"/>
<group name="ENROLLMENT">
<groupExpression>
<![CDATA[$F{ENROLLMENT}]]>
</groupExpression>
</group>
</subDataset>
<parameter name="SEM" class="java.lang.String"/>
<queryString>
<![CDATA[select * from sem_batch]]>
</queryString>
<field name="SEM" class="java.math.BigDecimal"/>
<field name="BATCH" class="java.lang.String"/>
<field name="BATCH_ID" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band splitType="Stretch" height="69">
<staticText>
<reportElement height="53" width="421" y="0" x="68"/>
<textElement markup="none" textAlignment="Center">
<font size="22"/>
</textElement>
<text>
<![CDATA[ATTENDANCE - CLASS ]]>
</text>
</staticText>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band splitType="Stretch" height="61">
<staticText>
<reportElement height="20" width="53" y="0" x="0"/>
<textElement>
<font size="12"/>
</textElement>
<text>
<![CDATA[SEM]]>
</text>
</staticText>
<staticText>
<reportElement height="20" width="53" y="20" x="0"/>
<textElement>
<font size="12"/>
</textElement>
<text>
<![CDATA[DATE]]>
</text>
</staticText>
<staticText>
<reportElement height="20" width="10" y="0" x="58"/>
<textElement/>
<text>
<![CDATA[:]]>
</text>
</staticText>
<staticText>
<reportElement height="20" width="10" y="20" x="58"/>
<textElement/>
<text>
<![CDATA[:]]>
</text>
</staticText>
<textField pattern="dd/MM/yyyy">
<reportElement height="20" width="100" y="20" x="68"/>
<textElement/>
<textFieldExpression>
<![CDATA[new java.util.Date()]]>
</textFieldExpression>
</textField>
<textField>
<reportElement height="20" width="100" y="0" x="68"/>
<textElement/>
<textFieldExpression>
<![CDATA[$P{SEM}]]>
</textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band splitType="Stretch" height="125">
<componentElement>
<reportElement height="50" width="360" y="0" x="35" style="table 5" key="table 5"/>
<jr:table
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"
xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components">
<datasetRun subDataset="a">
<datasetParameter name="sem">
<datasetParameterExpression>
<![CDATA[$P{SEM}+'%']]>
</datasetParameterExpression>
</datasetParameter>
<connectionExpression>
<![CDATA[$P{REPORT_CONNECTION}]]>
</connectionExpression>
</datasetRun>
<jr:column width="118">
<jr:columnHeader height="23" style="table 5_CH" rowSpan="1">
<staticText>
<reportElement height="20" width="118" y="0" x="0"/>
<textElement textAlignment="Center">
<font size="14" isBold="false"/>
</textElement>
<text>
<![CDATA[ENROLLMENT]]>
</text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20" style="table 5_TD" rowSpan="1">
<textField>
<reportElement height="20" width="118" y="0" x="0"/>
<textElement textAlignment="Center">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression>
<![CDATA[$F{ENROLLMENT}]]>
</textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:columnHeader height="23" style="table 5_CH" rowSpan="1">
<staticText>
<reportElement height="20" width="90" y="0" x="0"/>
<textElement textAlignment="Center">
<font size="14"/>
</textElement>
<text>
<![CDATA[SEM]]>
</text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20" style="table 5_TD" rowSpan="1">
<textField>
<reportElement height="20" width="90" y="0" x="0"/>
<textElement textAlignment="Center">
<font size="10"/>
</textElement>
<textFieldExpression>
<![CDATA[$F{SEM}]]>
</textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:columnHeader height="23" style="table 5_CH" rowSpan="1">
<staticText>
<reportElement height="20" width="90" y="0" x="0"/>
<textElement textAlignment="Center">
<font size="14"/>
</textElement>
<text>
<![CDATA[BATCH]]>
</text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20" style="table 5_TD" rowSpan="1">
<textField>
<reportElement height="20" width="90" y="0" x="0"/>
<textElement textAlignment="Center"/>
<textFieldExpression>
<![CDATA[$F{BATCH}]]>
</textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:columnHeader height="23" style="table 5_CH" rowSpan="1">
<staticText>
<reportElement height="20" width="90" y="0" x="0"/>
<textElement textAlignment="Center">
<font size="14"/>
</textElement>
<text>
<![CDATA[PRESENT]]>
</text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20" style="table 5_TD" rowSpan="1">
<textField>
<reportElement height="20" width="90" y="0" x="0"/>
<textElement textAlignment="Center"/>
<textFieldExpression>
<![CDATA[$F{PRESENT}]]>
</textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:columnHeader height="23" style="table 5_CH" rowSpan="1">
<staticText>
<reportElement height="20" width="90" y="0" x="0"/>
<textElement textAlignment="Center">
<font size="14"/>
</textElement>
<text>
<![CDATA[PERCENTAGE]]>
</text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20" style="table 5_TD" rowSpan="1">
<textField>
<reportElement height="20" width="90" y="0" x="0"/>
<textElement textAlignment="Center"/>
<textFieldExpression>
<![CDATA[$F{PERCENTAGE}]]>
</textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band splitType="Stretch" height="54">
<textField>
<reportElement height="20" width="100" y="16" x="227"/>
<textElement textAlignment="Center"/>
<textFieldExpression>
<![CDATA[$V{PAGE_NUMBER}]]>
</textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band splitType="Stretch" height="42"/>
</summary>
</jasperReport>
You should put the table component into the Title band (or into the Summary band, for example). Not into the Detail band.
Select Table Properties and add
printWhenExpression on the table to $V{REPORT_COUNT} == 1 Now to avoid repetation table values in your ireport.
Based on the previous answer response I was able with the table on the Detail section and the following properties set to avoid generating duplicated nor empty pages at the end of the document.
Detail Band -> set the Print When Expression with value $V{REPORT_COUNT} == 1
Table Element -> Set the Print When Expression $V{REPORT_COUNT} == 1
hey i got the solution of my problem. If in main query more than one rows are returned then such things will happen. Try to give query which returns not more than one row. Like "Select 1 from dual". This solution solved my problem.

How to filter data in table (crosstab) by date

I need some help in creating report using iReport for this layout. I am able to create records using crosstab, but its creating duplicate records.
Male Female
Date
Total Count
Query
SELECT table1.`gender` AS table1_gender,
registration_details.`date_reg` AS registration_details_date_reg
FROM
`table1` table1 INNER JOIN `date_reg` date_reg ON table1.`candidate_id` = registration_details.`candidate_id`
where
gender is present in table1 (candidate_id : pk)
date_reg is present in registration_details
The 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="report12" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<style name="Crosstab Data Text" hAlign="Center"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="New Dataset 1">
<queryString language="SQL">
<![CDATA[SELECT
table1.`gender` AS table1_gender,
registration_details.`date_reg` AS registration_details_date_reg
FROM
`table1` table1 INNER JOIN `date_reg` date_reg ON table1.`candidate_id` = registration_details.`candidate_id`]]>
</queryString>
<field name="table1_gender" class="java.lang.String"/>
<field name="registration_details_date_reg" class="java.sql.Date"/>
</subDataset>
<subDataset name="Table Dataset 1"/>
<queryString language="SQL">
<![CDATA[SELECT
table1.`gender` AS table1_gender,
registration_details.`date_reg` AS registration_details_date_reg
FROM
`table1` table1 INNER JOIN `date_reg` date_reg ON table1.`candidate_id` = registration_details.`candidate_id`]]>
</queryString>
<field name="table1_gender" class="java.lang.String"/>
<field name="date_reg" class="java.sql.Date"/>
<detail>
<band height="125" splitType="Stretch">
<crosstab>
<reportElement x="0" y="0" width="555" height="125"/>
<crosstabDataset>
<dataset>
<datasetRun subDataset="New Dataset 1">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
</dataset>
</crosstabDataset>
<rowGroup name="date_reg" width="70" totalPosition="End">
<bucket>
<bucketExpression class="java.lang.String"><![CDATA[(new SimpleDateFormat("yyyy-MM-dd")).format($F{date_reg})]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="Crosstab Data Text" x="0" y="0" width="70" height="25"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$V{date_reg}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<staticText>
<reportElement x="0" y="0" width="70" height="25"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Total date_reg]]></text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<columnGroup name="table1_gender" height="30" totalPosition="End">
<bucket>
<bucketExpression class="java.lang.String"><![CDATA[$F{table1_gender}]]></bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="30"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$V{student_gender}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<staticText>
<reportElement x="0" y="0" width="50" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Total student_gender]]></text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<measure name="table1_genderMeasure" class="java.lang.Integer" calculation="Count">
<measureExpression><![CDATA[$F{table1_gender}]]></measureExpression>
</measure>
<crosstabCell width="50" height="25">
<cellContents>
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25"/>
<textElement/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{table1_genderMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell height="25" rowTotalGroup="date_reg">
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25"/>
<textElement/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{table1_genderMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="50" columnTotalGroup="student_gender">
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25"/>
<textElement/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{table1_genderMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell rowTotalGroup="date_reg" columnTotalGroup="table1_gender">
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25"/>
<textElement/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{table1_genderMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
</crosstab>
</band>
</detail>
</jasperReport>
Currently its showing all the records , Need suggestions/help in creating report
Where a User will be able to fetch records by providing date.
also its printing single records multiple time.
I would appreciate any help.
For filtering data by date you can add paramater (java.lang.String or java.util.Date) type and use it in the query.
The example:
<parameter name="dateParam" isForPrompting="false" class="java.lang.String"/>
...
<parameter name="dqlDateFilter" isForPrompting="false" class="java.lang.String">
<defaultValueExpression ><![CDATA[$P{dateParam} == null ? "1=1" : "registration_details.date_reg=$P{dateParam}"]]></defaultValueExpression>
</parameter>
...
<queryString language="SQL">SELECT.... FROM.... WHERE $P!{dqlDateFilter}</queryString>
You should write the correct date filter for your case.