JasperReports在没有任何dataSource的情况下在JRXML中嵌入数据 [英] JasperReports Embed Data in JRXML without any dataSource

查看:188
本文介绍了JasperReports在没有任何dataSource的情况下在JRXML中嵌入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在没有任何dataSource的情况下将数据嵌入到报告模板(jrxml)中。我想在jrxml中静态写入我的数据,并显示包含此数据的表。这真的有可能吗?

I want to embed data in report template(jrxml) without any dataSource.I want to write my data staticly in jrxml,аnd display the table with this data. It is really possible?

推荐答案

你可以有一个列表变量并使用Java类将数据存储在其中。

You can have a list variable and store the data in it using Java class.


  1. 使用变量类列表或集合创建变量。

  2. 在变量表达式中输入返回名单。

如果你使用groovy同样的东西可以实现Groovy Collection。如果您想了解常规馆藏,请参阅更多内容。

If you are using groovy same thing can be achieved Groovy Collection. Here's more if you want to learn about groovy collections .

例如:

报告中有参数/变量

<parameter name="list_collect" class="java.util.List" isForPrompting="false">
  <defaultValueExpression><![CDATA[(new beandatasource()).OnFlyCollection()]]>                    </defaultValueExpression>
</parameter>

和Java类

package beandatasource;

import java.util.ArrayList;

public class OnFlyCollection {

    public ArrayList<String> ListCollect() {

        ArrayList<String> arr_list = new ArrayList<String>();
        arr_list.add("A");
        arr_list.add("B");
        arr_list.add("C");

        return arr_list;
    }
}

这篇关于JasperReports在没有任何dataSource的情况下在JRXML中嵌入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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