9

I'm trying to create a report with Jasper iReport 4.5 and I'm using a table to show some of the data. The table is filled by a query, and when I check the preview of the query in the Query Editor, I get exactly the results that I wanted. But when I try to create the preview of the report, all I get is "The document has no pages". Not even the static text in the table header is displayed.

Here is the XML of the report, but without the query:

<?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="subReportTextManualCustomerRating" pageWidth="500" pageHeight="842" columnWidth="460" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="ireport.zoom" value="1.4641000000000008"/>
    <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="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 1_CH" mode="Opaque" backcolor="#FFBFBF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="CustomerType">
        <parameter name="TEXT_MANUAL_OID" class="java.lang.String"/>
        <queryString>
        </queryString>
        <field name="Anzahl" class="java.lang.Long"/>
        <field name="Typ" class="java.lang.String"/>
        <field name="Bezeichnung" class="java.lang.String"/>
    </subDataset>
    <parameter name="TEXT_MANUAL_OID" class="java.lang.String"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <summary>
        <band height="143">
            <componentElement>
                <reportElement key="table 1" style="table 1" x="0" y="0" width="460" height="143"/>
                <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="CustomerType">
                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    </datasetRun>
                    <jr:column width="90">
                        <jr:tableHeader style="table 1_TH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30"/>
                                <textElement/>
                                <text><![CDATA[Kontakt Typen]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell style="table 1_TD" height="20">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="20"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{Typ}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="90">
                        <jr:tableHeader style="table 1_TH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30"/>
                                <textElement/>
                                <text><![CDATA[Ergebniserklärung]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell style="table 1_TD" height="20">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="20"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{Bezeichnung}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="90">
                        <jr:tableHeader style="table 1_TH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30"/>
                                <textElement/>
                                <text><![CDATA[Anzahl der Kontakte]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:detailCell style="table 1_TD" height="20">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="20"/>
                                <textElement/>
                                <textFieldExpression><![CDATA[$F{Anzahl}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </summary>
</jasperReport>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Stefan Schmitt
  • 215
  • 1
  • 2
  • 9
  • 1
    Did you create datasource for report? You should set relevant datasource as active (in `iReport`). What datasource (xml or something else) are you using? – Alex K Mar 05 '12 at 14:00
  • Yes, I have a valid datasource and I set the table to use the main report datasource – Stefan Schmitt Mar 05 '12 at 14:02
  • 1
    Ok, I just found out what it was. I had to create a query for the main report, even though I dont use it anywhere in this report. So I just added select 1 as dummy_field as query for the main report, and now the table shows the data I want. Sadly, I can only answer my own question in 7 hours because my account is new. – Stefan Schmitt Mar 05 '12 at 14:04
  • @Stefan you can add your comment as an answer and mark it as accepted even though it is your own question. – Jacob Schoen Mar 06 '12 at 18:52

3 Answers3

14

There is an another method.

Follow below step

  1. Click on main report name
  2. choose property name: when no data type
  3. choose property value: all section no detail

By using this there is no need to add dummy sql.

Fahad Anjum
  • 1,246
  • 1
  • 10
  • 19
11

Ok, I just found out what it was. I had to create a query for the main report, even though I dont use it anywhere in this report. So I just added "select 1 as dummy_field" as query for the main report, and now the table shows the data I want.

Stefan Schmitt
  • 215
  • 1
  • 2
  • 9
2

In my case, I have provided empty data source and problem resolved

JasperPrint jasperPrint = JasperFillManager.fillReport(path,null, new JREmptyDataSource());
NIrav Modi
  • 6,038
  • 8
  • 32
  • 47