我的Jasper模板没有显示任何文字 [英] My Jasper Template shows no text

查看:175
本文介绍了我的Jasper模板没有显示任何文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前不确定为什么如果我运行我的这个示例模板,我看不到任何文字。

I am currently unsure why if I ran this sample template of mine, I cannot see any text.

<?xml version="1.0"?>
<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="SampleReport" pageWidth="798" pageHeight="1000">
    <title>
        <band height="50">
          <staticText>
            <reportElement x="0" y="0" width="180" height="15"/>
            <textElement/>
            <text>
              <![CDATA[Sample Title]]>
            </text>
          </staticText>
        </band>
      </title>
    <detail>
        <band height="20">
            <staticText>
                <reportElement x="20" y="0" width="200" height="20"/>
                <text>
                    <![CDATA[Sample Text]]>
                </text>
            </staticText>
        </band>
    </detail>
</jasperReport>

我用ant任务来运行这个测试。

I used ant task to run this test like this.

<target name="viewDesignXML"
    <java classname="net.sf.jasperreports.view.JasperDesignViewer"
        fork="true">
        <arg value="-XML" />
        <arg value="-F${file.name}.jrxml" />
        <classpath refid="classpath" />
    </java>
</target>

这是带有eclipse 3.6的Jasperreport 4.5

This is Jasperreport 4.5 with eclipse 3.6

谢谢

推荐答案

您没有指定数据源,因此报告的原因是空的。

You did not specify the datasource and so the cause of your report is empty.

您可以设置 whenNoDataType 无数据时 属性在iReport中)报告的属性用于显示空报告。

You can set whenNoDataType (When No Data property in iReport) report's attribute for showing "empty" report.

此属性的可能值为:


  • 无页面:生成的文档在
    中没有页面。尝试加载此类文档时,查看者可能会抛出错误
    whenNoDataType =NoPages)。

  • 空白页:生成的文档将包含一个空白页
    whenNoDataType =BlankPage)。

  • 所有部分,无详细信息:除 详细信息 部分(带)之外的所有报告部分都将显示在生成的文档中( whenNoDataType =AllSectionsNoDetail)。

  • 无数据部分:生成的文档只包含一个 noData 部分(乐队)
    whenNoDataType =NoDataSection)。

  • No Pages: The generated document will have no pages in it. Viewers might throw an error when trying to load such documents (whenNoDataType="NoPages").
  • Blank Page: The generated document will contain a single blank page (whenNoDataType="BlankPage").
  • All Sections, No Detail: All the report sections except the Detail section (band) will appear in the generated document (whenNoDataType="AllSectionsNoDetail").
  • No Data Section: The generated document will contain only a single noData section (band) (whenNoDataType="NoDataSection").

如果使用 noData 部分,您应该将此频段添加到报告的模板中(例如,在iReport的帮助下) )。

In case using noData section you should add this band to the report's template (for example, with help of iReport).

当您使用这样的Java代码时:

When you are using the Java code like this:

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
       map, new JREmptyDataSource());

这意味着您传递的是空数据源,换句话说就是没有传递数据源。

it means that you are passing the empty datasource or in other words did not pass the datasource.

如果您没有传递数据源和数据库连接,则只能在报告中显示数据 - 通过参数传递数据(或初始化报告模板中的参数)

In case you did not pass datasource and database connection the only chance to show the data at report - is to pass data via parameters (or initialize parameters inside the report's template)

这篇关于我的Jasper模板没有显示任何文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆