title: iReport: Getting multiple copies of table in detail band
body: <p>I am new at <code>iReport</code>. So I want to make a simple report based on data. </p>
  
  <p>My problem is when my rows are less then detail band's size the whole table gets repeated in detail band, and I dont want it again. If my rows are aproximately 5, then same table gets copied 4 times in detail band, and not only table but each and every thing I put in detail band. It gets repeated itself till detail band limits come. </p>
  
  <p>So am I making some mistake, or I have to set some property of detail band in <code>iReport</code>? </p>
  
  <p>please help me friends. Thanks in advance.</p>
  
  <p>This is the generated result:</p>
  
  <p><img src="https://i.stack.imgur.com/5ffvy.png" alt="Generated result"></p>
  
  <p>Here is my code of jrxml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jasperReport language="groovy" bottomMargin="20" topMargin="20" rightMargin="20" leftMargin="20" columnWidth="555"
                whenNoDataType="AllSectionsNoDetail" pageHeight="842" pageWidth="595" name="test"
                xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="http://jasperreports.sourceforge.net/jasperreports"&gt;
      &lt;property name="ireport.zoom" value="1.0"/&gt;
      &lt;property name="ireport.x" value="0"/&gt;
      &lt;property name="ireport.y" value="0"/&gt;
      &lt;style name="table"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="1.0"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table_TH" backcolor="#F0F8FF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table_CH" backcolor="#BFE1FF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table_TD" backcolor="#FFFFFF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 1"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="1.0"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 1_TH" backcolor="#F0F8FF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 1_CH" backcolor="#BFE1FF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 1_TD" backcolor="#FFFFFF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 2"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="1.0"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 2_TH" backcolor="#F0F8FF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 2_CH" backcolor="#BFE1FF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 2_TD" backcolor="#FFFFFF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 3"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="1.0"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 3_TH" backcolor="#F0F8FF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 3_CH" backcolor="#BFE1FF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 3_TD" backcolor="#FFFFFF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 4"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="1.0"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 4_TH" backcolor="#F0F8FF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 4_CH" backcolor="#BFE1FF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 4_TD" backcolor="#FFFFFF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 5"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="1.0"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 5_TH" backcolor="#F0F8FF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 5_CH" backcolor="#BFE1FF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;style name="table 5_TD" backcolor="#FFFFFF" mode="Opaque"&gt;
          &lt;box&gt;
              &lt;pen lineColor="#000000" lineWidth="0.5"/&gt;
          &lt;/box&gt;
      &lt;/style&gt;
      &lt;subDataset name="a"&gt;
          &lt;parameter name="sem" class="java.lang.String"&gt;
              &lt;defaultValueExpression&gt;
                  &lt;![CDATA[]]&gt;
              &lt;/defaultValueExpression&gt;
          &lt;/parameter&gt;
          &lt;queryString&gt;
              &lt;![CDATA[select final."M" as "ENROLLMENT",sem_batch.sem,sem_batch.batch,final."N" as "TTL_WKDY",final."O" as "PRESENT",round(((100*"O")/"N"),2) as "PERCENTAGE" from sem_batch, (select m."Std_id" as "M",l."Batch" as "L",l."Btch" as "N",m."Std" as "O" from (select count(b.batch_id) as "Btch",b.batch_id as "Batch" from batch_wkday b where b.batch_id like $P{sem} group by batch_id) l, (select count(a.std_id) as "Std",a.std_id as "Std_id",s.batch_id as "Batch" from attendance a,student_detail s where a.std_id=s.std_id and s.batch_id like $P{sem} group by a.std_id,s.batch_id) m where l."Batch"=m."Batch") final where final."L"=sem_batch.batch_id]]&gt;
          &lt;/queryString&gt;
          &lt;field name="ENROLLMENT" class="java.math.BigDecimal"/&gt;
          &lt;field name="SEM" class="java.math.BigDecimal"/&gt;
          &lt;field name="BATCH" class="java.lang.String"/&gt;
          &lt;field name="TTL_WKDY" class="java.math.BigDecimal"/&gt;
          &lt;field name="PRESENT" class="java.math.BigDecimal"/&gt;
          &lt;field name="PERCENTAGE" class="java.math.BigDecimal"/&gt;
          &lt;group name="ENROLLMENT"&gt;
              &lt;groupExpression&gt;
                  &lt;![CDATA[$F{ENROLLMENT}]]&gt;
              &lt;/groupExpression&gt;
          &lt;/group&gt;
      &lt;/subDataset&gt;
      &lt;parameter name="SEM" class="java.lang.String"/&gt;
      &lt;queryString&gt;
          &lt;![CDATA[select * from sem_batch]]&gt;
      &lt;/queryString&gt;
      &lt;field name="SEM" class="java.math.BigDecimal"/&gt;
      &lt;field name="BATCH" class="java.lang.String"/&gt;
      &lt;field name="BATCH_ID" class="java.lang.String"/&gt;
      &lt;background&gt;
          &lt;band splitType="Stretch"/&gt;
      &lt;/background&gt;
      &lt;title&gt;
          &lt;band splitType="Stretch" height="69"&gt;
              &lt;staticText&gt;
                  &lt;reportElement height="53" width="421" y="0" x="68"/&gt;
                  &lt;textElement markup="none" textAlignment="Center"&gt;
                      &lt;font size="22"/&gt;
                  &lt;/textElement&gt;
                  &lt;text&gt;
                      &lt;![CDATA[ATTENDANCE - CLASS ]]&gt;
                  &lt;/text&gt;
              &lt;/staticText&gt;
          &lt;/band&gt;
      &lt;/title&gt;
      &lt;pageHeader&gt;
          &lt;band splitType="Stretch"/&gt;
      &lt;/pageHeader&gt;
      &lt;columnHeader&gt;
          &lt;band splitType="Stretch" height="61"&gt;
              &lt;staticText&gt;
                  &lt;reportElement height="20" width="53" y="0" x="0"/&gt;
                  &lt;textElement&gt;
                      &lt;font size="12"/&gt;
                  &lt;/textElement&gt;
                  &lt;text&gt;
                      &lt;![CDATA[SEM]]&gt;
                  &lt;/text&gt;
              &lt;/staticText&gt;
              &lt;staticText&gt;
                  &lt;reportElement height="20" width="53" y="20" x="0"/&gt;
                  &lt;textElement&gt;
                      &lt;font size="12"/&gt;
                  &lt;/textElement&gt;
                  &lt;text&gt;
                      &lt;![CDATA[DATE]]&gt;
                  &lt;/text&gt;
              &lt;/staticText&gt;
              &lt;staticText&gt;
                  &lt;reportElement height="20" width="10" y="0" x="58"/&gt;
                  &lt;textElement/&gt;
                  &lt;text&gt;
                      &lt;![CDATA[:]]&gt;
                  &lt;/text&gt;
              &lt;/staticText&gt;
              &lt;staticText&gt;
                  &lt;reportElement height="20" width="10" y="20" x="58"/&gt;
                  &lt;textElement/&gt;
                  &lt;text&gt;
                      &lt;![CDATA[:]]&gt;
                  &lt;/text&gt;
              &lt;/staticText&gt;
              &lt;textField pattern="dd/MM/yyyy"&gt;
                  &lt;reportElement height="20" width="100" y="20" x="68"/&gt;
                  &lt;textElement/&gt;
                  &lt;textFieldExpression&gt;
                      &lt;![CDATA[new java.util.Date()]]&gt;
                  &lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField&gt;
                  &lt;reportElement height="20" width="100" y="0" x="68"/&gt;
                  &lt;textElement/&gt;
                  &lt;textFieldExpression&gt;
                      &lt;![CDATA[$P{SEM}]]&gt;
                  &lt;/textFieldExpression&gt;
              &lt;/textField&gt;
          &lt;/band&gt;
      &lt;/columnHeader&gt;
      &lt;detail&gt;
          &lt;band splitType="Stretch" height="125"&gt;
              &lt;componentElement&gt;
                  &lt;reportElement height="50" width="360" y="0" x="35" style="table 5" key="table 5"/&gt;
                  &lt;jr:table
                          xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"
                          xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components"&gt;
                      &lt;datasetRun subDataset="a"&gt;
                          &lt;datasetParameter name="sem"&gt;
                              &lt;datasetParameterExpression&gt;
                                  &lt;![CDATA[$P{SEM}+'%']]&gt;
                              &lt;/datasetParameterExpression&gt;
                          &lt;/datasetParameter&gt;
                          &lt;connectionExpression&gt;
                              &lt;![CDATA[$P{REPORT_CONNECTION}]]&gt;
                          &lt;/connectionExpression&gt;
                      &lt;/datasetRun&gt;
                      &lt;jr:column width="118"&gt;
                          &lt;jr:columnHeader height="23" style="table 5_CH" rowSpan="1"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement height="20" width="118" y="0" x="0"/&gt;
                                  &lt;textElement textAlignment="Center"&gt;
                                      &lt;font size="14" isBold="false"/&gt;
                                  &lt;/textElement&gt;
                                  &lt;text&gt;
                                      &lt;![CDATA[ENROLLMENT]]&gt;
                                  &lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:columnHeader&gt;
                          &lt;jr:detailCell height="20" style="table 5_TD" rowSpan="1"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement height="20" width="118" y="0" x="0"/&gt;
                                  &lt;textElement textAlignment="Center"&gt;
                                      &lt;font size="10" isBold="false"/&gt;
                                  &lt;/textElement&gt;
                                  &lt;textFieldExpression&gt;
                                      &lt;![CDATA[$F{ENROLLMENT}]]&gt;
                                  &lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                      &lt;jr:column width="90"&gt;
                          &lt;jr:columnHeader height="23" style="table 5_CH" rowSpan="1"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement height="20" width="90" y="0" x="0"/&gt;
                                  &lt;textElement textAlignment="Center"&gt;
                                      &lt;font size="14"/&gt;
                                  &lt;/textElement&gt;
                                  &lt;text&gt;
                                      &lt;![CDATA[SEM]]&gt;
                                  &lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:columnHeader&gt;
                          &lt;jr:detailCell height="20" style="table 5_TD" rowSpan="1"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement height="20" width="90" y="0" x="0"/&gt;
                                  &lt;textElement textAlignment="Center"&gt;
                                      &lt;font size="10"/&gt;
                                  &lt;/textElement&gt;
                                  &lt;textFieldExpression&gt;
                                      &lt;![CDATA[$F{SEM}]]&gt;
                                  &lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                      &lt;jr:column width="90"&gt;
                          &lt;jr:columnHeader height="23" style="table 5_CH" rowSpan="1"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement height="20" width="90" y="0" x="0"/&gt;
                                  &lt;textElement textAlignment="Center"&gt;
                                      &lt;font size="14"/&gt;
                                  &lt;/textElement&gt;
                                  &lt;text&gt;
                                      &lt;![CDATA[BATCH]]&gt;
                                  &lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:columnHeader&gt;
                          &lt;jr:detailCell height="20" style="table 5_TD" rowSpan="1"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement height="20" width="90" y="0" x="0"/&gt;
                                  &lt;textElement textAlignment="Center"/&gt;
                                  &lt;textFieldExpression&gt;
                                      &lt;![CDATA[$F{BATCH}]]&gt;
                                  &lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                      &lt;jr:column width="90"&gt;
                          &lt;jr:columnHeader height="23" style="table 5_CH" rowSpan="1"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement height="20" width="90" y="0" x="0"/&gt;
                                  &lt;textElement textAlignment="Center"&gt;
                                      &lt;font size="14"/&gt;
                                  &lt;/textElement&gt;
                                  &lt;text&gt;
                                      &lt;![CDATA[PRESENT]]&gt;
                                  &lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:columnHeader&gt;
                          &lt;jr:detailCell height="20" style="table 5_TD" rowSpan="1"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement height="20" width="90" y="0" x="0"/&gt;
                                  &lt;textElement textAlignment="Center"/&gt;
                                  &lt;textFieldExpression&gt;
                                      &lt;![CDATA[$F{PRESENT}]]&gt;
                                  &lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                      &lt;jr:column width="90"&gt;
                          &lt;jr:columnHeader height="23" style="table 5_CH" rowSpan="1"&gt;
                              &lt;staticText&gt;
                                  &lt;reportElement height="20" width="90" y="0" x="0"/&gt;
                                  &lt;textElement textAlignment="Center"&gt;
                                      &lt;font size="14"/&gt;
                                  &lt;/textElement&gt;
                                  &lt;text&gt;
                                      &lt;![CDATA[PERCENTAGE]]&gt;
                                  &lt;/text&gt;
                              &lt;/staticText&gt;
                          &lt;/jr:columnHeader&gt;
                          &lt;jr:detailCell height="20" style="table 5_TD" rowSpan="1"&gt;
                              &lt;textField&gt;
                                  &lt;reportElement height="20" width="90" y="0" x="0"/&gt;
                                  &lt;textElement textAlignment="Center"/&gt;
                                  &lt;textFieldExpression&gt;
                                      &lt;![CDATA[$F{PERCENTAGE}]]&gt;
                                  &lt;/textFieldExpression&gt;
                              &lt;/textField&gt;
                          &lt;/jr:detailCell&gt;
                      &lt;/jr:column&gt;
                  &lt;/jr:table&gt;
              &lt;/componentElement&gt;
          &lt;/band&gt;
      &lt;/detail&gt;
      &lt;columnFooter&gt;
          &lt;band splitType="Stretch"/&gt;
      &lt;/columnFooter&gt;
      &lt;pageFooter&gt;
          &lt;band splitType="Stretch" height="54"&gt;
              &lt;textField&gt;
                  &lt;reportElement height="20" width="100" y="16" x="227"/&gt;
                  &lt;textElement textAlignment="Center"/&gt;
                  &lt;textFieldExpression&gt;
                      &lt;![CDATA[$V{PAGE_NUMBER}]]&gt;
                  &lt;/textFieldExpression&gt;
              &lt;/textField&gt;
          &lt;/band&gt;
      &lt;/pageFooter&gt;
      &lt;summary&gt;
          &lt;band splitType="Stretch" height="42"/&gt;
      &lt;/summary&gt;
  &lt;/jasperReport&gt;
  </code></pre>