How to do group using table component, not fields? - jasper-reports

The goal is to make something like that using groups
The problem is that I can construct it using fields, but when I export the report constructed from fields (like in most of tutorials) to Excel, it becomes a mess.
I want to use table component, maybe partly, just for the parts where row1, row2... etc are located, because tables are exported rather decently.
Is that possible at all?
If I add a table component into the details band, it shows the whole table for each group (all rows 1-9 are in each group, so I have no grouping at all), like here:
This 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="report1" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="8075ffe7-6e3e-430c-9792-0842e1047ee7">
<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>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#EFF7FF"/>
</conditionalStyle>
</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>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#EFF7FF"/>
</conditionalStyle>
</style>
<subDataset name="New Dataset 1" uuid="6d70e59b-520c-4c3a-b122-fc299a1e36f3">
<queryString language="SQL">
<![CDATA[select * from test_table]]>
</queryString>
<field name="COLUMN1" class="java.lang.String"/>
<field name="INITIATOR" class="java.lang.String"/>
<field name="ID" class="java.lang.String"/>
<field name="URL" class="java.lang.String"/>
<field name="DOMAIN" class="java.lang.String"/>
</subDataset>
<queryString>
<![CDATA[select * from test_table]]>
</queryString>
<field name="COLUMN1" class="java.lang.String"/>
<field name="INITIATOR" class="java.lang.String"/>
<field name="ID" class="java.lang.String"/>
<field name="URL" class="java.lang.String"/>
<field name="DOMAIN" class="java.lang.String"/>
<group name="USER">
<groupExpression><![CDATA[$F{INITIATOR}]]></groupExpression>
<groupHeader>
<band height="20">
<textField>
<reportElement x="0" y="0" width="100" height="20" uuid="f3c7aeda-d5fc-4745-aa57-6b86527bca7d"/>
<textFieldExpression><![CDATA[$F{INITIATOR}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
</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="82" splitType="Stretch">
<componentElement>
<reportElement key="table 1" style="table 1" x="0" y="0" width="802" height="80" uuid="1e1e5c70-7231-407c-8a21-8a8abe18004c"/>
<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="c1fc144a-34ea-4a3c-bad5-979e248dbdd5">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="164" uuid="6fc1588c-ff53-457e-9ded-bf2ef1499ef9">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="164" height="30" uuid="37471666-30cf-4fba-a25a-2341517a9ff8"/>
<text><![CDATA[COLUMN1]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table 1_CH" height="30" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="164" height="20" uuid="23a35d1a-1835-4f98-b948-2e20d170b7cb"/>
<textFieldExpression><![CDATA[$F{COLUMN1}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="143" uuid="3bb44350-b9a3-42f3-a4b4-24cc92c1ac7a">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="143" height="30" uuid="32882a4d-9af7-4d20-bffc-d97304f852ec"/>
<text><![CDATA[INITIATOR]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table 1_CH" height="30" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="143" height="20" uuid="624c6056-9c8d-469d-834e-052e7ba64205"/>
<textFieldExpression><![CDATA[$F{INITIATOR}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="145" uuid="fdc25f77-cbf8-437b-9599-8dac13c231c7">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="145" height="30" uuid="9def11e0-f333-4af6-acd2-87693f546b94"/>
<text><![CDATA[ID]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table 1_CH" height="30" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="145" height="20" uuid="bffecf39-515f-49fa-a2fd-dce3b899664a"/>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="215" uuid="ebcc9292-c0f8-45d7-acfb-a0cd07411c06">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="215" height="30" uuid="119558f5-9f63-408d-88fe-685bff93420c"/>
<text><![CDATA[URL]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table 1_CH" height="30" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="215" height="20" uuid="57fb4ae3-2ef8-46f5-9078-189afba2cc6f"/>
<textFieldExpression><![CDATA[$F{URL}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="134" uuid="f241a40c-8426-4b4f-ad01-fcda25e3891c">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="134" height="30" uuid="d3015f10-9258-4ac9-8e95-a00f450b751e"/>
<text><![CDATA[DOMAIN]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table 1_CH" height="30" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="134" height="20" uuid="fab1275a-7ae9-443b-8861-fa7c319e01b1"/>
<textFieldExpression><![CDATA[$F{DOMAIN}]]></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>

I have edited your jrxml. I passed id from the main query to the table component as parameter and used it in the query for where condition, so the table query will only return the rows which are related to the parent query id.
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" language="groovy" pageWidth="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="125"/>
<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>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#EFF7FF"/>
</conditionalStyle>
</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>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#EFF7FF"/>
</conditionalStyle>
</style>
<subDataset name="New Dataset 1">
<parameter name="id" class="java.lang.Integer">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select * from test_table where id = $P{id};]]>
</queryString>
<field name="COLUMN1" class="java.lang.String"/>
<field name="INITIATOR" class="java.lang.String"/>
<field name="ID" class="java.lang.String"/>
<field name="URL" class="java.lang.String"/>
<field name="DOMAIN" class="java.lang.String"/>
</subDataset>
<queryString>
<![CDATA[select * from test_table;]]>
</queryString>
<field name="COLUMN1" class="java.lang.String"/>
<field name="INITIATOR" class="java.lang.String"/>
<field name="ID" class="java.lang.String"/>
<field name="URL" class="java.lang.String"/>
<field name="DOMAIN" class="java.lang.String"/>
<group name="USER">
<groupExpression><![CDATA[$F{INITIATOR}]]></groupExpression>
<groupHeader>
<band height="20">
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textFieldExpression><![CDATA[$F{INITIATOR}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
</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="82" splitType="Stretch">
<componentElement>
<reportElement key="table 1" style="table 1" x="0" y="0" width="802" height="80"/>
<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">
<datasetParameter name="id">
<datasetParameterExpression><![CDATA[$F{ID}]]></datasetParameterExpression>
</datasetParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="164">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="164" height="30"/>
<text><![CDATA[COLUMN1]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table 1_CH" height="30" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="164" height="20"/>
<textFieldExpression><![CDATA[$F{COLUMN1}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="143">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="143" height="30"/>
<text><![CDATA[INITIATOR]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table 1_CH" height="30" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="143" height="20"/>
<textFieldExpression><![CDATA[$F{INITIATOR}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="145">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="145" height="30"/>
<text><![CDATA[ID]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table 1_CH" height="30" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="145" height="20"/>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="215">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="215" height="30"/>
<text><![CDATA[URL]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table 1_CH" height="30" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="215" height="20"/>
<textFieldExpression><![CDATA[$F{URL}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="134">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="134" height="30"/>
<text><![CDATA[DOMAIN]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table 1_CH" height="30" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="134" height="20"/>
<textFieldExpression><![CDATA[$F{DOMAIN}]]></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>

Related

Create a table in iReports using XmlDataSource

I'm trying to create a table using XmlDataSource, but it neither printing the table structure nor showing the data. I'm using iReport 4.7.1. Kindly help.
What I have done is:
Created a new blank report
Created an xml datasource
Selected /sendDetail/results as the record node
Created a table with the selected fields
Below is the .jrxml file I'm using:
<?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="testReport2" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a19f4e39-052a-483f-834a-5546d7626590">
<property name="ireport.zoom" value="1.5"/>
<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>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#EFF7FF"/>
</conditionalStyle>
</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>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#EFF7FF"/>
</conditionalStyle>
</style>
<subDataset name="Dataset" uuid="601a324d-5c44-4688-b6d4-cf64b3869ba4">
<queryString language="xPath">
<![CDATA[/sendDetail/results]]>
</queryString>
<field name="results" class="java.lang.String">
<fieldDescription><![CDATA[child::text()]]></fieldDescription>
</field>
<field name="effDate" class="java.lang.String">
<fieldDescription><![CDATA[effDate]]></fieldDescription>
</field>
<field name="period" class="java.lang.String">
<fieldDescription><![CDATA[period]]></fieldDescription>
</field>
<field name="amount" class="java.lang.String">
<fieldDescription><![CDATA[amount]]></fieldDescription>
</field>
<field name="totalAmount" class="java.lang.String">
<fieldDescription><![CDATA[totalAmount]]></fieldDescription>
</field>
<field name="description" class="java.lang.String">
<fieldDescription><![CDATA[description]]></fieldDescription>
</field>
</subDataset>
<queryString language="xPath">
<![CDATA[/sendDetail/results]]>
</queryString>
<field name="effDate" class="java.lang.String">
<fieldDescription><![CDATA[effDate]]></fieldDescription>
</field>
<field name="period" class="java.lang.String">
<fieldDescription><![CDATA[period]]></fieldDescription>
</field>
<field name="amount" class="java.lang.String">
<fieldDescription><![CDATA[amount]]></fieldDescription>
</field>
<field name="totalAmount" class="java.lang.String">
<fieldDescription><![CDATA[totalAmount]]></fieldDescription>
</field>
<field name="description" class="java.lang.String">
<fieldDescription><![CDATA[description]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="65" splitType="Stretch">
<componentElement>
<reportElement uuid="9bed609a-a1cf-489d-a7b0-d322f0dfc9db" key="table 1" style="table 1" x="0" y="0" width="555" height="65"/>
<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="Dataset" uuid="33620359-7c04-4c08-9f6c-a18d9c5eb044">
<connectionExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_CONNECTION}).subDataSource("/sendDetail/results")]]></connectionExpression>
</datasetRun>
<jr:column uuid="9403d18c-6eec-447b-b8d2-c4973350060a" width="90">
<jr:columnHeader style="table 1_CH" height="30">
<staticText>
<reportElement uuid="b86bb6ed-aee3-40b0-976e-bc4c23408910" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[effDate]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20">
<textField>
<reportElement uuid="de8b3535-74da-41b4-9f1d-7b66164bb0dc" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{effDate}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="ee9a667a-8916-4d87-87b7-e256e90e7682" width="90">
<jr:columnHeader style="table 1_CH" height="30">
<staticText>
<reportElement uuid="3d173f1a-776d-415b-b241-ba4b4416a829" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[period]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20">
<textField>
<reportElement uuid="9d6db0e4-6b13-4af3-9060-9057246e4e63" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{period}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="d178a594-0faf-4a05-969c-2e17e65e9121" width="90">
<jr:columnHeader style="table 1_CH" height="30">
<staticText>
<reportElement uuid="41a37b97-55be-45cb-8279-354d460ded19" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[amount]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20">
<textField>
<reportElement uuid="9e7714bc-3f8b-4d1e-8f77-ab8e9b14617f" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{amount}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="e2cdad6a-fd55-4b35-9fc9-c6c93f8d3c0e" width="90">
<jr:columnHeader style="table 1_CH" height="30">
<staticText>
<reportElement uuid="b2d16a10-e73a-404d-8435-445664399482" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[totalAmount]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20">
<textField>
<reportElement uuid="ea85d3b8-23e4-4c24-a611-d099b4a6d242" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{totalAmount}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="e4a14c01-5159-41e2-b8eb-5fa333c8cc6c" width="90">
<jr:columnHeader style="table 1_CH" height="30">
<staticText>
<reportElement uuid="0beaa2b0-6b2c-46d5-97ff-36a1888bd7b8" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[description]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20">
<textField>
<reportElement uuid="9b34870c-6013-47b5-af29-3380fbda1b25" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{description}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
</jasperReport>
Below is the xml file:
<sendDetail>
<results>
<effDate>2015-10-20</effDate>
<period>DEC 1;2015 TO FEB 29;2016</period>
<amount>177.48</amount>
<totalAmount>177.48</totalAmount>
<description>Premium</description>
</results>
<results>
<effDate>2015-10-20</effDate>
<period>DEC 1;2015 TO FEB 29;2016</period>
<amount>-177.48</amount>
<totalAmount>0</totalAmount>
<description>Premium Cancellation</description>
</results>
<results>
<effDate>2015-07-20</effDate>
<period>SEP 1;2015 TO NOV 30;2015</period>
<amount>-177.48</amount>
<totalAmount>0</totalAmount>
<description>Premium Cancellation</description>
</results>
<results>
<effDate>2015-07-20</effDate>
<period>SEP 1;2015 TO NOV 30;2015</period>
<amount>177.48</amount>
<totalAmount>177.48</totalAmount>
<description>Premium</description>
</results>
</sendDetail>
You need to:
Change your main dataSet's queryString to:
<queryString language="xPath">
<![CDATA[/]]>
</queryString>
Replace your table's datasetRun declaration with:
<datasetRun subDataset="Dataset" uuid="33620359-7c04-4c08-9f6c-a18d9c5eb044">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/sendDetail/results")]]></dataSourceExpression>
</datasetRun>

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).

JasperReport iReport: JRException: Error retrieving field value from bean

I'm trying to understand how iReport works and how to create a simple jrxml file.
The report has a title and header and the data should be in a table. When I try to check how the report looks like using the preview button, I could see the title and header but not the table (Please note that I use that I clicked the "Use default value" for all fields). When I did not use the default value, I get this error.
Error filling print... net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : name
net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : name 
    at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:809) 
    at net.sf.jasperreports.components.table.fill.FillTableSubreport.prepareSubreport(FillTableSubreport.java:156) 
    at net.sf.jasperreports.components.table.fill.FillTable.prepare(FillTable.java:400) 
    at net.sf.jasperreports.engine.fill.JRFillComponentElement.prepare(JRFillComponentElement.java:151) 
Caused by: net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : name 
    at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:123) 
    at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getFieldValue(JRAbstractBeanDataSource.java:96) 
    at net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.getFieldValue(JRBeanCollectionDataSource.java:109) 
Caused by: java.lang.NoSuchMethodException: Unknown property 'name' on class 'class java.lang.String' 
    at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1322) 
    at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:770) 
    at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:846) 
    at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426) 
    at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:111) 
    ... 15 more  Print not filled. Try to use an EmptyDataSource...
I thought that maybe that problem has something to do with how I typed the data for List. Probably the format is wrong. This is how I typed the sample data
(myName, 5, Manila)
(Based on the screenshot, Is the format correct? I even tried enclosing it in a square bracket but I still get the same error.)
please note that I have 3 columns Name , Age , Address.
But in the error message I noticed this
Unknown property 'name' on class 'class java.lang.String' 
which makes me think that I did something wrong when I create the dataset. (Sorry if I used a wrong term).
Anyway, here's the xml generated by iReport.
<?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="firstReport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="597c0716-df6b-42ec-a7c8-863eb1b7174a">
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#7FFFD4">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFFFEA">
<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="#7FFFD4">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFFFEA">
<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="Table Dataset 2" uuid="208e382c-09df-484e-8d2d-a4eb4f4e48ba">
<field name="name" class="java.lang.String"/>
<field name="age" class="java.lang.String"/>
<field name="address" class="java.lang.String"/>
</subDataset>
<parameter name="companyName" class="java.lang.String"/>
<parameter name="date" class="java.util.Date"/>
<parameter name="bean" class="java.util.List"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="32" splitType="Stretch">
<staticText>
<reportElement x="182" y="0" width="184" height="25" uuid="fe64d4b4-efb1-4ed2-ae06-772728fc8b65"/>
<textElement>
<font fontName="Bookman Old Style" size="15" isBold="true"/>
</textElement>
<text><![CDATA[Chart Of Account List]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="58" splitType="Stretch">
<staticText>
<reportElement x="13" y="0" width="100" height="20" uuid="52ae4669-b47e-408c-aabc-e8f470a1d92b"/>
<text><![CDATA[Company]]></text>
</staticText>
<staticText>
<reportElement x="13" y="38" width="100" height="20" uuid="a27fe0e1-9fe6-423f-a006-46c51c7e3e5e"/>
<text><![CDATA[Date Exported]]></text>
</staticText>
<textField>
<reportElement x="113" y="0" width="100" height="20" uuid="1d600fa2-9de4-4999-9222-98a8bcb484f9"/>
<textFieldExpression><![CDATA[$P{companyName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="113" y="38" width="100" height="20" uuid="1147b818-90ae-4b41-a757-19a590db41d7"/>
<textFieldExpression><![CDATA[$P{date}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<componentElement>
<reportElement key="table 1" style="table 1" x="13" y="0" width="270" height="50" uuid="652523bf-b666-47bc-a1aa-fc20fb9e489a"/>
<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="Table Dataset 2" uuid="6fcb9950-2d3f-4752-b56d-df7bff1e6991">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{bean})]]></dataSourceExpression>
</datasetRun>
<jr:column width="90" uuid="ee62967c-3669-49fe-a70d-a588ae47439d">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="a0973bfe-815a-498e-8b25-c3320cfe0f62"/>
<text><![CDATA[Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="61d8309e-dd7d-4978-b171-9ae9144e2f5c"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="76a9e313-d134-420e-898b-7f5f444c4efb">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="f79fdf71-a673-4d3a-8e10-b986d99b8e9b"/>
<text><![CDATA[Age]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="e4342bed-af9c-4541-9e57-a24485d0a94d"/>
<textFieldExpression><![CDATA[$F{age}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="5c38c250-d74e-440c-93cb-3fef8ad38157">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="4656a074-f345-483a-971b-b00c95746ec0"/>
<text><![CDATA[Address]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="f2cc3d1c-97ef-48c1-b6e4-a12acc4e67ad"/>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
</jasperReport>
1) What is wrong with the jrxml that I made? Did I supply a wrong formatted data to the table? Or there's just something wrong with how I did the report?
This was fixed by adding "new" keyword in the datasource expression. You will see datasource expression by right clicking table in the Report Inspector. "edit Table Datasource"

inserting break in table to print only 10 rows per page in jasper reports 3.7.2

I have a jasper code that prints report in a table format and the values for the report are passed from the java class during the run time and i am using jasper reports 3.7.2 jar to print the report. The jasper code is as follows:
<?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="grouping_on_zipcode_basis" pageWidth="1400" pageHeight="750" orientation="Landscape" isIgnorePagination="true" columnWidth="1300" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" isFloatColumnFooter="true" >
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="ireport.scriptlethandling" value="0"/>
<property name="ireport.encoding" value="UTF-8"/>
<import value="net.sf.jasperreports.engine.*"/>
<import value="java.util.*"/>
<import value="net.sf.jasperreports.engine.data.*"/>
<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" forecolor="#FFFFFF" backcolor="#006F3A">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#57A7E8">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
<conditionalStyle>
<conditionExpression><![CDATA[Boolean.valueOf($V{REPORT_COUNT}.intValue() % 2 == 0)]]></conditionExpression>
<style backcolor="#FFFFFF"/>
</conditionalStyle>
</style>
<subDataset name="tableDataset" >
<field name="participantName" class="java.lang.String"/>
<field name="Ssn" class="java.lang.String"/>
<field name="Zipcode" class="java.lang.String"/>
</subDataset>
<field name="Ssn" class="java.lang.String"/>
<field name="Zipcode" class="java.lang.String"/>
<background>
<band />
</background>
<title>
<band height="200">
<componentElement>
<reportElement key="table" style="table" x="146" y="150" width="299" height="46" isRemoveLineWhenBlank="true" />
<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">
<datasetParameter name="REPORT_DATA_SOURCE">
<datasetParameterExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></datasetParameterExpression>
</datasetParameter>
</datasetRun>
<jr:column width="90" >
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" />
<text><![CDATA[PARTICIPANT NAME]]></text></staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" >
</reportElement>
<textFieldExpression><![CDATA[$F{participantName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" >
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" >
<printWhenExpression><![CDATA[new Boolean($F{Ssn}!= null)]]></printWhenExpression>
</reportElement>
<text><![CDATA[SSN]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement isRemoveLineWhenBlank="true" x="0" y="0" width="90" height="20" />
<textFieldExpression><![CDATA[$F{Ssn}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" >
<printWhenExpression><![CDATA[new Boolean($F{Zipcode}!= null)]]></printWhenExpression>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" >
<printWhenExpression><![CDATA[new Boolean($F{Zipcode}!= null)]]></printWhenExpression>
</reportElement>
<text><![CDATA[ZIPCODE]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement isRemoveLineWhenBlank="true" x="0" y="0" width="90" height="20" />
<textFieldExpression><![CDATA[$F{participantZip}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</title>
<columnFooter>
<band />
</columnFooter>
<pageFooter>
<band />
</pageFooter>
<summary>
<band />
</summary>
</jasperReport>
Now i want to print only 10 rows per table and the upcoming values must be print on a new table in the next page and it goes on. But all the tables must contain only 10 rows. Please help me..!
I found a way. We can insert a column break at the end of the detail cell with a "print when expression". The code is as follows:
<jr:detailCell style="table_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="18"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{participantName}]]></textFieldExpression>
</textField>
<break type="Column">
<reportElement x="0" y="19" width="90" height="1">
<printWhenExpression><![CDATA[new java.lang.Boolean((int)($V{REPORT_COUNT}.intValue())%10==0)]]></printWhenExpression>
</reportElement>
</break>
</jr:detailCell>

How to create Jasper Report Table component with Group By?

The standard column layout can use to achieve this. How can I do it for the table component layout?
It is quite easy. You should add new datasource for Table component and then use it (datasource) in this component.
The sample jrxml:
<?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>
<subDataset name="tableDataset">
<queryString language="SQL">
<![CDATA[SELECT id, city, street FROM address ORDER BY city]]>
</queryString>
<field name="ID" class="java.lang.Integer"/>
<field name="CITY" class="java.lang.String"/>
<field name="STREET" class="java.lang.String"/>
<group name="CITY">
<groupExpression><![CDATA[$F{CITY}]]></groupExpression>
</group>
</subDataset>
<title>
<band height="58" splitType="Stretch">
<componentElement>
<reportElement key="table" style="table" x="0" y="0" width="299" height="46"/>
<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">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="90">
<jr:groupHeader groupName="CITY">
<jr:cell height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{CITY}]]></textFieldExpression>
</textField>
</jr:cell>
</jr:groupHeader>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[Id]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[Street]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{STREET}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</title>
</jasperReport>
The design in iReport looks like this:
The main report view:
The Table component view:
In this sample I've delete the main datasource and put the Table component to the Title band. I've set whenNoDataType="AllSectionsNoDetail" property for displaying report.
The data in report is grouped by city field.