Issue with repeating values in iReport/JasperReports 3.6.1

◇◆丶佛笑我妖孽 提交于 2019-12-23 03:22:12

问题


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

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

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

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.

Does anyone have any ideas?

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.


回答1:


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.]

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.



来源:https://stackoverflow.com/questions/9354352/issue-with-repeating-values-in-ireport-jasperreports-3-6-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!