在iReport / JasperReports 3.6.1中重复值的问题 [英] Issue with repeating values in iReport/JasperReports 3.6.1

查看:124
本文介绍了在iReport / JasperReports 3.6.1中重复值的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iReport来格式化查询结果。结果目前是这样的:

I am using iReport's to format the results of a query. The results are currently something like this:

Id   firstname surname  -  id    firstname  surname
1      dan      n          45      dan        n
1      dan      n          46      dan        n
3      john     d          102     john       d
4      john     f          109     john       f
4      john     f          110     john       f

我希望它们看起来更像这样:

I would like them to look more like this:

Id   firstname surname  -  id    firstname  surname
1      dan      n          45      dan        n
                           46      dan        n
3      john     d          102     john       d
4      john     f          109     john       f
                           110     john       f

我知道iReport具有'重复值时打印功能,但如果我使用此功能我发生了以下情况:

I know that iReport has the 'print when Repeated Values feature, but if i use this I get the following happening:

Id   firstname surname  -  id    firstname  surname
1      dan      n          45      dan        n
                           46      dan        n
3      john     d          102     john       d
4               f          109     john       f
                           110     john       f

因为iReports将第二个John视为重复,所以将其删除。

Because iReports recognises the second John as a repeat and so removes it.

所以我的问题是,有没有办法做到这一点?我无法找到一种方法来对元素进行分组,然后不在id字段上重复。我试着跟踪最后2个id,然后打印当前是否与最后一个匹配,但是无法弄清楚如何让它每次更新以便跟踪。

So my question is, is there a way to do this? I have not been able to find a way to group the elements and then not repeat on the id field. I tried playing around with keeping track of the last 2 id's and then printing on whether the current matches the last, but haven't been able to figure out how to get it to update each time so that it keeps track.

有没有人有任何想法?

我正在使用ireport(和jasperreports)3.6.1并且知道要查询将返回我需要的内容,但希望格式化在报告端完成。

I am using ireport (and jasperreports) 3.6.1 and know to make a query that will return what i need but would rather that the formatting is done on the report side.

推荐答案

在<$ c上创建一个组$ c> $ F {Id} 名为MyGroup。不要创建组页眉或组页脚。 [此时,您的报告仍然与第一个版本完全一样。]

Create a group on $F{Id} called MyGroup. Don't create a group header or group footer. [At this point your report will still look exactly as it does in your first version.]

然后在每个字段中添加Print When Expression:Id,firstname,姓。表达式应如下所示:

Then add a Print When Expression to each of these fields: Id, firstname, surname. The Expression should look like this:

new Boolean($V{MyGroup_COUNT}.intValue()==1)

这样你就可以按照身份证打印一次字段。

That let's you print your fields once per ID.

这篇关于在iReport / JasperReports 3.6.1中重复值的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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