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>
Related
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).
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>
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>
I am a newbie to JasperReports. When I try to add values to table in the columns the column header and footer are getting repeated. How should I group column header.
My 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="report1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="551344a1-61b0-419c-92a0-5ebe6f8d4219">
<property name="ireport.zoom" value="1.2100000000000004"/>
<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>
<style name="table 2">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 2_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Table Dataset 1" uuid="75c6059a-1e76-45b2-a87c-14792e68956e">
<field name="training" class="java.lang.String"/>
<field name="trainingPeriod" class="java.lang.String"/>
<field name="traingingAdd" class="java.lang.String"/>
<field name="noofgovtorderauth" class="java.lang.String"/>
<field name="authapprovingentry" class="java.lang.String"/>
<field name="deptTestpassed" class="java.lang.String"/>
<field name="athConducTest" class="java.lang.String"/>
<field name="monthSptestPassed" class="java.lang.String"/>
<field name="yrSpTestPassed" class="java.lang.String"/>
<field name="regNo" class="java.lang.String"/>
</subDataset>
<parameter name="ReportName" class="java.lang.String"/>
<parameter name="Date" class="java.lang.String"/>
<parameter name="Title" class="java.lang.String"/>
<parameter name="SubTitle" class="java.lang.String"/>
<parameter name="FooterDetail" class="java.lang.String"/>
<parameter name="govtlogo" class="java.lang.String"/>
<parameter name="TNWRDLogo" class="java.lang.String"/>
<field name="training" class="java.lang.String">
<fieldDescription><![CDATA[training]]></fieldDescription>
</field>
<field name="trainingPeriod" class="java.lang.String"/>
<field name="traingingAdd" class="java.lang.String"/>
<field name="noofgovtorderauth" class="java.lang.String"/>
<field name="authapprovingentry" class="java.lang.String"/>
<field name="deptTestpassed" class="java.lang.String"/>
<field name="athConducTest" class="java.lang.String"/>
<field name="monthSptestPassed" class="java.lang.String"/>
<field name="yrSpTestPassed" class="java.lang.String"/>
<field name="regNo" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<frame>
<reportElement uuid="fd5eaed7-88e8-4980-8205-6e50cf99ef20" x="0" y="27" width="565" height="52">
<property name="net.sf.jasperreports.export.pdf.tag.h1"/>
<property name="net.sf.jasperreports.export.pdf.tag.tr" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textField>
<reportElement uuid="d3615141-0461-4665-b5f4-46a10f968d0e" x="174" y="33" width="213" height="19"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{SubTitle}]]></textFieldExpression>
</textField>
<image>
<reportElement uuid="34b5159e-3eb2-450a-9536-f79813589d48" x="442" y="2" width="61" height="48"/>
<imageExpression><![CDATA[$P{TNWRDLogo}]]></imageExpression>
</image>
<image>
<reportElement uuid="cd0f7d86-105f-44a1-8c27-81feacfba469" x="65" y="0" width="98" height="51"/>
<imageExpression><![CDATA[$P{govtlogo}]]></imageExpression>
</image>
<textField>
<reportElement uuid="e8aee322-2336-4637-9a5c-cb51af5995c8" x="174" y="0" width="213" height="32"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{Title}]]></textFieldExpression>
</textField>
</frame>
</band>
</title>
<pageHeader>
<band height="35" splitType="Stretch">
<textField>
<reportElement uuid="4c89127c-2b66-447e-af83-7ffd210e8a19" x="174" y="5" width="213" height="24"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{ReportName}]]></textFieldExpression>
</textField>
<frame>
<reportElement uuid="4ba70858-74c9-48a0-9690-888636570607" x="0" y="0" width="565" height="35"/>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
</frame>
</band>
</pageHeader>
<columnHeader>
<band height="23" splitType="Stretch">
<staticText>
<reportElement uuid="479cad61-a5be-4318-8e81-850ba6626e59" x="27" y="0" width="100" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Training Detail]]></text>
</staticText>
<staticText>
<reportElement uuid="d3474389-b724-4579-81b6-2f5c806aaa25" x="432" y="0" width="100" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Special Tests Passed]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<componentElement>
<reportElement uuid="f2abf631-2415-4ba1-bf93-4b1d458dacbc" key="table 2" style="table 2" x="53" y="44" width="450" 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="Table Dataset 1" uuid="69dfdbc6-34fc-48ee-8ecd-197cde9b11fb">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource(1)]]></dataSourceExpression>
</datasetRun>
<jr:columnGroup width="450" uuid="7287994d-bc5c-4286-8607-29969a2eb9ef">
<jr:column width="90" uuid="dbd24c78-fb82-47c4-9342-d5a73fb7e000">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="74b27263-d281-4136-b674-12bd3a74bd3c" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Training]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="be34b5c1-5cd4-43e3-b6f9-0e6f2bbf88db" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{training}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="01a9c90b-46c3-4693-b186-7abc77256f73">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="5ada3627-2084-4d79-a923-b6acbeee8058" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Period / Duration]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="abb64036-38ea-4560-84fd-09dde730c3bc" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{trainingPeriod}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="0865e4a3-5dbe-430a-9c50-90a636ef49ef">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="a897110e-f09f-43f3-a53b-aa8450065832" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Impart Training Address]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="41f45483-1f6d-480c-a59c-96093111ace5" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{traingingAdd}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="8949efe8-7041-49dd-8631-685e8568e6d5">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="643bb124-0b66-448d-ade8-c7b540f18eb5" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[No of Government Orders]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="834227d7-673a-4335-b1f8-37b3892125b1" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{noofgovtorderauth}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="7fa15b45-3110-4648-ab41-35fc77c625d6">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="cfd20c24-75f4-449e-83ae-38d9e0507728" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[ Approving Audthority]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="b5e5dec0-46d3-47b5-aefe-5fe2038c94b9" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{authapprovingentry}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:columnGroup>
</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>
Try this , It will work for you.
<?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" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="551344a1-61b0-419c-92a0-5ebe6f8d4219">
<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>
<style name="table 2">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 2_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Table Dataset 1" uuid="75c6059a-1e76-45b2-a87c-14792e68956e">
<field name="training" class="java.lang.String"/>
<field name="trainingPeriod" class="java.lang.String"/>
<field name="traingingAdd" class="java.lang.String"/>
<field name="noofgovtorderauth" class="java.lang.String"/>
<field name="authapprovingentry" class="java.lang.String"/>
<field name="deptTestpassed" class="java.lang.String"/>
<field name="athConducTest" class="java.lang.String"/>
<field name="monthSptestPassed" class="java.lang.String"/>
<field name="yrSpTestPassed" class="java.lang.String"/>
<field name="regNo" class="java.lang.String"/>
</subDataset>
<parameter name="ReportName" class="java.lang.String"/>
<parameter name="Date" class="java.lang.String"/>
<parameter name="Title" class="java.lang.String"/>
<parameter name="SubTitle" class="java.lang.String"/>
<parameter name="FooterDetail" class="java.lang.String"/>
<parameter name="govtlogo" class="java.lang.String"/>
<parameter name="TNWRDLogo" class="java.lang.String"/>
<field name="training" class="java.lang.String">
<fieldDescription><![CDATA[training]]></fieldDescription>
</field>
<field name="trainingPeriod" class="java.lang.String"/>
<field name="traingingAdd" class="java.lang.String"/>
<field name="noofgovtorderauth" class="java.lang.String"/>
<field name="authapprovingentry" class="java.lang.String"/>
<field name="deptTestpassed" class="java.lang.String"/>
<field name="athConducTest" class="java.lang.String"/>
<field name="monthSptestPassed" class="java.lang.String"/>
<field name="yrSpTestPassed" class="java.lang.String"/>
<field name="regNo" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="114" splitType="Stretch">
<frame>
<reportElement uuid="fd5eaed7-88e8-4980-8205-6e50cf99ef20" x="0" y="27" width="565" height="52">
<property name="net.sf.jasperreports.export.pdf.tag.h1"/>
<property name="net.sf.jasperreports.export.pdf.tag.tr" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textField>
<reportElement uuid="d3615141-0461-4665-b5f4-46a10f968d0e" x="174" y="33" width="213" height="19"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{SubTitle}]]></textFieldExpression>
</textField>
<image>
<reportElement uuid="34b5159e-3eb2-450a-9536-f79813589d48" x="442" y="2" width="61" height="48"/>
<imageExpression><![CDATA[$P{TNWRDLogo}]]></imageExpression>
</image>
<image>
<reportElement uuid="cd0f7d86-105f-44a1-8c27-81feacfba469" x="65" y="0" width="98" height="51"/>
<imageExpression><![CDATA[$P{govtlogo}]]></imageExpression>
</image>
<textField>
<reportElement uuid="e8aee322-2336-4637-9a5c-cb51af5995c8" x="174" y="0" width="213" height="32"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{Title}]]></textFieldExpression>
</textField>
</frame>
</band>
</title>
<pageHeader>
<band height="35" splitType="Stretch">
<textField>
<reportElement uuid="4c89127c-2b66-447e-af83-7ffd210e8a19" x="174" y="5" width="213" height="24"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{ReportName}]]></textFieldExpression>
</textField>
<frame>
<reportElement uuid="4ba70858-74c9-48a0-9690-888636570607" x="0" y="0" width="565" height="35"/>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
</frame>
</band>
</pageHeader>
<columnHeader>
<band height="23" splitType="Stretch">
<printWhenExpression><![CDATA[$V{REPORT_COUNT} == 1]]></printWhenExpression>
<staticText>
<reportElement uuid="479cad61-a5be-4318-8e81-850ba6626e59" x="27" y="0" width="100" height="22">
<printWhenExpression><![CDATA[$V{REPORT_COUNT} == 1]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Training Detail]]></text>
</staticText>
<staticText>
<reportElement uuid="d3474389-b724-4579-81b6-2f5c806aaa25" x="432" y="0" width="100" height="22">
<printWhenExpression><![CDATA[$V{REPORT_COUNT} == 1]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Special Tests Passed]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<componentElement>
<reportElement uuid="f2abf631-2415-4ba1-bf93-4b1d458dacbc" key="table 2" style="table 2" x="53" y="44" width="450" 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="Table Dataset 1" uuid="69dfdbc6-34fc-48ee-8ecd-197cde9b11fb">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource(1)]]></dataSourceExpression>
</datasetRun>
<jr:columnGroup uuid="7287994d-bc5c-4286-8607-29969a2eb9ef" width="450">
<jr:column uuid="dbd24c78-fb82-47c4-9342-d5a73fb7e000" width="90">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="74b27263-d281-4136-b674-12bd3a74bd3c" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Training]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="be34b5c1-5cd4-43e3-b6f9-0e6f2bbf88db" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{training}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="01a9c90b-46c3-4693-b186-7abc77256f73" width="90">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="5ada3627-2084-4d79-a923-b6acbeee8058" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Period / Duration]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="abb64036-38ea-4560-84fd-09dde730c3bc" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{trainingPeriod}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="0865e4a3-5dbe-430a-9c50-90a636ef49ef" width="90">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="a897110e-f09f-43f3-a53b-aa8450065832" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Impart Training Address]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="41f45483-1f6d-480c-a59c-96093111ace5" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{traingingAdd}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="8949efe8-7041-49dd-8631-685e8568e6d5" width="90">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="643bb124-0b66-448d-ade8-c7b540f18eb5" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[No of Government Orders]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="834227d7-673a-4335-b1f8-37b3892125b1" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{noofgovtorderauth}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="7fa15b45-3110-4648-ab41-35fc77c625d6" width="90">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="cfd20c24-75f4-449e-83ae-38d9e0507728" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[ Approving Audthority]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="b5e5dec0-46d3-47b5-aefe-5fe2038c94b9" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{authapprovingentry}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:columnGroup>
</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>
Enjoy....
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.