0

我正在尝试使用 Table 组件生成JR报告。但是生成的 PDF 文件中没有显示任何数据。也没有错误。

请告诉我在这里做错了什么?

数据源:JavaBeans (POJO)

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="org-report" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20"
    bottomMargin="20">
    <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="test-data-set">
        <queryString>
            <![CDATA[]]>
        </queryString>
        <field name="orgDskUsage" class="java.lang.Double">
            <fieldDescription><![CDATA[orgDskUsage]]></fieldDescription>
        </field>
        <field name="orgId" class="java.lang.Integer">
            <fieldDescription><![CDATA[orgId]]></fieldDescription>
        </field>
        <field name="orgMsgSize" class="java.lang.Double">
            <fieldDescription><![CDATA[orgMsgSize]]></fieldDescription>
        </field>
        <field name="orgName" class="java.lang.String">
            <fieldDescription><![CDATA[orgName]]></fieldDescription>
        </field>
    </subDataset>
    <queryString>
        <![CDATA[]]>
    </queryString>

    <field name="orgDskUsage" class="java.lang.Double">
        <fieldDescription><![CDATA[orgDskUsage]]></fieldDescription>
    </field>
    <field name="orgId" class="java.lang.Integer">
        <fieldDescription><![CDATA[orgId]]></fieldDescription>
    </field>
    <field name="orgMsgSize" class="java.lang.Double">
        <fieldDescription><![CDATA[orgMsgSize]]></fieldDescription>
    </field>
    <field name="orgName" class="java.lang.String">
        <fieldDescription><![CDATA[orgName]]></fieldDescription>
    </field>

    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="41" splitType="Stretch">
            <staticText>
                <reportElement x="112" y="0" width="297" height="30"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font size="12"/>
                </textElement>
                <text><![CDATA[Organisation Report]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="179" splitType="Stretch">
            <componentElement>
                <reportElement key="table" style="table" x="91" y="15" width="360" height="140"/>
                <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="test-data-set">
                        <!-- <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource(OrgDataSource.getOrgList())]]></dataSourceExpression> -->
                         <datasetParameter name="REPORT_DATA_SOURCE">
                            <datasetParameterExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></datasetParameterExpression>
                        </datasetParameter>
                    </datasetRun>
                    <jr:column width="90">
                        <jr:tableHeader style="table_TH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Org Id]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:tableFooter style="table_TH" height="30"/>
                        <jr:columnHeader style="table_CH" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="30"/>
                                <textElement/>
                                <textFieldExpression class="java.lang.Integer"><![CDATA[$F{orgId}]]></textFieldExpression>
                            </textField>
                        </jr:columnHeader>
                        <jr:columnFooter style="table_CH" height="30"/>
                        <jr:detailCell style="table_TD" height="20"/>
                    </jr:column>
                    <jr:column width="90">
                        <jr:tableHeader style="table_TH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Org Name]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:tableFooter style="table_TH" height="30"/>
                        <jr:columnHeader style="table_CH" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="30"/>
                                <textElement/>
                                <textFieldExpression class="java.lang.String"><![CDATA[$F{orgName}]]></textFieldExpression>
                            </textField>
                        </jr:columnHeader>
                        <jr:columnFooter style="table_CH" height="30"/>
                        <jr:detailCell style="table_TD" height="20"/>
                    </jr:column>
                    <jr:column width="90">
                        <jr:tableHeader style="table_TH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Msg Dsk usage]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:tableFooter style="table_TH" height="30"/>
                        <jr:columnHeader style="table_CH" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="30"/>
                                <textElement/>
                                <textFieldExpression class="java.lang.Double"><![CDATA[$F{orgDskUsage}]]></textFieldExpression>
                            </textField>
                        </jr:columnHeader>
                        <jr:columnFooter style="table_CH" height="30"/>
                        <jr:detailCell style="table_TD" height="20"/>
                    </jr:column>
                    <jr:column width="90">
                        <jr:tableHeader style="table_TH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Msg Size]]></text>
                            </staticText>
                        </jr:tableHeader>
                        <jr:tableFooter style="table_TH" height="30"/>
                        <jr:columnHeader style="table_CH" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="30"/>
                                <textElement/>
                                <textFieldExpression class="java.lang.Double"><![CDATA[$F{orgMsgSize}]]></textFieldExpression>
                            </textField>
                        </jr:columnHeader>
                        <jr:columnFooter style="table_CH" height="30"/>
                        <jr:detailCell style="table_TD" height="20"/>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </columnHeader>
    <columnFooter>
        <band splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

报告日志

2013-06-01 15:16:11,804 DEBUG [qtp1926506456-396] JRXmlDigesterFactory: Using SAX parser factory class net.sf.jasperreports.engine.xml.JRReportSaxParserFactory
2013-06-01 15:16:11,805 DEBUG [qtp1926506456-396] JRXmlDigesterFactory: Instantiated SAX parser factory of type org.apache.xerces.jaxp.SAXParserFactoryImpl
2013-06-01 15:16:11,806 DEBUG [qtp1926506456-396] JRXmlDigesterFactory: Adding components schema at jar:file:/opt/opennms/lib/jasperreports-3.7.6.jar!/net/sf/jasperreports/       components/components.xsd
2013-06-01 15:16:11,806 DEBUG [qtp1926506456-396] JRXmlDigesterFactory: Instantiating grammar pool of type org.apache.xerces.util.XMLGrammarPoolImpl for cache key                 WebAppClassLoader=opennms@49ab4552
2013-06-01 15:16:11,849 DEBUG [qtp1926506456-396] SpringExtensionsRegistry: Getting bean org.opennms.netmgt.jasper.OnmsQueryExecutorFactoryBundle#0 as extension of type net.sf.   jasperreports.engine.query.QueryExecuterFactoryBundle
2013-06-01 15:16:11,850 DEBUG [qtp1926506456-396] SpringExtensionsRegistry: Getting bean org.opennms.netmgt.jasper.OnmsQueryExecutorFactoryBundle#0 as extension of type net.sf.   jasperreports.engine.query.QueryExecuterFactoryBundle
2013-06-01 15:16:11,852 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,853 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,853 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,853 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,853 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,854 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,854 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,854 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,854 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,854 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,855 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,855 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,855 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,855 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,855 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,856 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,856 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,856 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,856 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,856 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,857 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,857 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,857 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,858 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,858 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,858 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,858 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,858 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,858 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,858 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,859 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,859 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,859 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,859 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,859 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,860 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,860 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,860 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,860 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Pushing report context for dataset name test-data-set
2013-06-01 15:16:11,860 DEBUG [qtp1926506456-396] TableReportContextXmlRule: Popping report context
2013-06-01 15:16:11,862 DEBUG [qtp1926506456-396] SpringExtensionsRegistry: Getting bean org.opennms.netmgt.jasper.OnmsQueryExecutorFactoryBundle#0 as extension of type net.sf.   jasperreports.engine.query.QueryExecuterFactoryBundle
4

1 回答 1

0

您的问题是您没有任何查询来提取任何数据。你定义了你的领域,但你没有什么可以填写的。

在您的基本报告中,您需要一些数据,以便您的表格显示其他明智的 jasper 认为报告是空白的,我通常使用一些非常简单的东西,例如

select sysdate from dual 

然后在您的数据集中,您还需要一个查询来提取您的数据

select orgDskUsage,orgID,orgMsgSize,OrgName from dual

当然,您需要将 from 更改为您的表格

在您的代码中添加第 25 行

<![CDATA[select orgDskUsage,orgID,orgMsgSize,OrgName from dual]]>

和第 41 行

<![CDATA[select sysdate from dual ]]>
于 2013-06-05T15:00:30.810 回答