How to show an empty table in iReport 3.0.0

ireportjasper-reports

I'm modifying an existing iReport file, one that supposedly asks for an input from a program. The input is then placed in a table, which I assume, automatically adds rows as the data comes in.

However, the program isn't putting out the data, and is no longer required to do so. So now I only need an empty table to be displayed.

What I've done in iReport is to remove all traces of parameters (since they are no longer needed, and copy and paste all the cells until they reach the bottom of the page. Now none of the cells (except the header, and top row, because they have static text) are visible, and one of the reports even went as far as displaying a blank page.

I've tried setting the Report Properties: When No Data: to either No Data Section, or All Sections-No Detail, but it's still empty with no visible cells. I've also tried putting a space in the textfields, hoping that it would show, and even replacing them with rectangles (which worked in another report). However, nothing worked. The reports still show only the header.

How can I fix this? Thanks.

Here's the JRXML:

<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
         name="ApprenticeEmployment1"
         columnCount="1"
         printOrder="Vertical"
         orientation="Landscape"
         pageWidth="1008"
         pageHeight="612"
         columnWidth="948"
         columnSpacing="0"
         leftMargin="30"
         rightMargin="30"
         topMargin="20"
         bottomMargin="20"
         whenNoDataType="AllSectionsNoDetail"
         isTitleNewPage="false"
         isSummaryNewPage="false">
    <property name="ireport.scriptlethandling" value="0" />
    <property name="ireport.encoding" value="UTF-8" />
    <import value="java.util.*" />
    <import value="net.sf.jasperreports.engine.*" />
    <import value="net.sf.jasperreports.engine.data.*" />

    <parameter name="imagedir" isForPrompting="false" class="java.lang.String"/>

    <field name="REGION" class="java.lang.String"/>
    <field name="PROVINCE" class="java.lang.String"/>
    <field name="FULL_QUALIFICATION" class="java.lang.String"/>
    <field name="DELIVERY" class="java.lang.String"/>
    <field name="SECTOR" class="java.lang.String"/>
    <field name="STUDENT_ID" class="java.lang.String"/>
    <field name="LAST_NAME" class="java.lang.String"/>
    <field name="FIRST_NAME" class="java.lang.String"/>
    <field name="MI" class="java.lang.String"/>
    <field name="CONTACT_NUMBER" class="java.lang.String"/>
    <field name="E_MAIL" class="java.lang.String"/>
    <field name="STREET" class="java.lang.String"/>
    <field name="BARANGAY" class="java.lang.String"/>
    <field name="CITY" class="java.lang.String"/>
    <field name="SEX" class="java.lang.String"/>
    <field name="DOB" class="java.lang.String"/>
    <field name="AGE" class="java.math.BigDecimal"/>
    <field name="CIVIL_STAT" class="java.lang.String"/>
    <field name="EDUC_LEVEL" class="java.lang.String"/>
    <field name="DATE_STARTED" class="java.lang.String"/>
    <field name="DATE_FINISHED" class="java.lang.String"/>
    <field name="REMARKS" class="java.lang.String"/>

        <background>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </background>
        <title>
            <band height="51"  isSplitAllowed="true" >
                <staticText>
                    <reportElement
                        x="0"
                        y="30"
                        width="948"
                        height="21"
                        key="staticText-1"/>
                    <box></box>
                    <textElement textAlignment="Center" verticalAlignment="Bottom">
                        <font pdfFontName="Helvetica-Bold" isBold="true"/>
                    </textElement>
                <text><![CDATA[Apprentice Report Form]]></text>
                </staticText>
                <image  hAlign="Center" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                    <reportElement
                        x="238"
                        y="0"
                        width="470"
                        height="37"
                        key="image-1"/>
                    <box></box>
                    <graphicElement stretchType="NoStretch"/>
                    <imageExpression class="java.lang.String"><![CDATA[$P{imagedir}+"goldilocks-small.JPG"]]></imageExpression>
                </image>
            </band>
        </title>
        <pageHeader>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </pageHeader>
        <columnHeader>
            <band height="65"  isSplitAllowed="true" >
                <staticText>
                    <reportElement
                        x="0"
                        y="18"
                        width="34"
                        height="31"
                        key="staticText-3"/>
                    <box>                   <topPen lineWidth="0.25"/>
                    <leftPen lineWidth="0.25"/>
                    <bottomPen lineWidth="0.25"/>
                    <rightPen lineWidth="0.25"/>
</box>
                    <textElement textAlignment="Center" verticalAlignment="Middle">
                        <font/>
                    </textElement>
                <text><![CDATA[Sex]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="271"
                        y="18"
                        width="58"
                        height="31"
                        key="staticText-4"/>
                    <box>                   <topPen lineWidth="0.25"/>
                    <leftPen lineWidth="0.25"/>
                    <bottomPen lineWidth="0.25"/>
                    <rightPen lineWidth="0.25"/>
</box>
                    <textElement textAlignment="Center" verticalAlignment="Middle">
                        <font/>
                    </textElement>
                <text><![CDATA[Scholarship]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="453"
                        y="18"
                        width="42"
                        height="31"
                        key="staticText-5"/>
                    <box>                   <topPen lineWidth="0.25"/>
                    <leftPen lineWidth="0.25"/>
                    <bottomPen lineWidth="0.25"/>
                    <rightPen lineWidth="0.25"/>
</box>
                    <textElement textAlignment="Center" verticalAlignment="Middle">
                        <font/>
                    </textElement>
                <text><![CDATA[Client Type
]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="0"
                        y="1"
                        width="741"
                        height="17"
                        key="staticText-6"/>
            </band>
        </columnHeader>
        <detail>
            <band height="456"  isSplitAllowed="true" >
                <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                    <reportElement
                        x="0"
                        y="432"
                        width="34"
                        height="18"
                        key="textField-378"
                        stretchType="RelativeToTallestObject"
                        positionType="Float"/>
                    <textElement verticalAlignment="Middle">
                        <font size="8"/>
                    </textElement>
                <textFieldExpression   class="java.lang.String"><![CDATA[]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                    <reportElement
                        x="0"
                        y="72"
                        width="34"
                        height="18"
                        key="textField-458"
                        stretchType="RelativeToTallestObject"
                        positionType="Float"/>
                    <textElement verticalAlignment="Middle">
                        <font size="8"/>
                    </textElement>
                <textFieldExpression   class="java.lang.String"><![CDATA[]]></textFieldExpression>
                </textField>
            </band>
        </detail>
        <columnFooter>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </columnFooter>
        <pageFooter>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </pageFooter>
        <summary>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </summary>
</jasperReport>

I did edit out a lot of 'boxes' though, so if the format's wrong, that's me and not the JRXML itself.

Regards,
Zack_Falcon

Best Solution

To create a table with N empty records, even you don't have data.

  1. create a object table
  2. attach your DataSEt to this table or use an empty data source
  3. select your table in the "Report inspector" and click right
  4. select : "Edit table Datasource"
  5. in the window you write: new net.sf.jasperreports.engine.JREmptyDataSource(44)
  6. run your report

44 is the number to display empty records.

Related Question