通过“where condition”到jasperreports导出pdf [英] passing a "where condition" to jasperreports exporting pdf

查看:224
本文介绍了通过“where condition”到jasperreports导出pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的SQL表,有两个属性和三行:

A simple SQL table, with two attributes and three rows:


reference |名称:

reference | name:

0 |第一个

1 |第二个

2 |第三个

我有一个带有Swing的Java应用程序,通过JList显示这个(每一行连接两个字符串,引用和名称) 。

I have a Java application, with Swing, showing this through a JList (each row concatenates the two strings, reference and name).

我按下一个按钮,我使用从iReport编译的from_ireport.jasper成功导出整个数据库。我也可以从代码编译。

I push a button, I export the entire database successfully, using my "from_ireport.jasper", compiled from iReport. I can compile from code too.

我想选择一个或多个元素,按下按钮并获得仅包含所选元素的pdf。我在哪里以及如何指定jasper的where condition?

I want to select one or more elements, push the button and get a pdf with just the selected elements. Where and how do I specify the "where condition" to jasper?

我找不到一个简单的例子来查看。
谢谢。

I can't find a easy example to look at. Thanks.

推荐答案

要解决此问题,您可以使用 JR 报告的参数。

For solving this issue you can use the JR report's parameters.

例如,您可以使用此查询表达式:

For example you can use this query expression:

<queryString>
        <![CDATA[SELECT reference, name FROM table WHERE $P!{whereCondition}]]>
</queryString>

传递参数值的Java代码示例:

The sample of Java code for passing parameter's value:

Map<String, Object> params = new HashMap<String, Object>();
params.put("whereCondition", "reference > 0");
JasperReport jasperReport = JasperCompileManager.compileReport(reportSource);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, connection);






有关详细信息,请查看查询示例

这篇关于通过“where condition”到jasperreports导出pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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