组内每隔 5 行加一个分隔线

【问题】

I have grouped the data on the column “state” and set the pagebreak option to “Always Excluding First” so that I can see the data related to a particular state in a separate page.

I’m trying to add a horizontal line after every 5 rows in the group. How can I do that??

I tried to add a line and set the visibility property to “Hide Element”, selected the radio button “For specific output” and wrote the expression "Birt.Math((row._rownum+1),5)!=0". At first, it looked like a solution, but for the next group, the rownum is not “zero”.

http://www.birt-exchange.org/org/forum/public/style_emoticons/ default/confused.gif How can I reset the “rownum” to zero for every first row in the group so that I can see the horizontal line after every 5 rows(starting from the first row in that group, but not the first row in the table) in the next groups?

To say it more clear, if I have 2 groups and in the first group(which is in the first page) I have 17 rows. In the second group (which is in the second page), I have 18 rows. When I tried to add the expression for the visibility(mentioned above), I could see the horizontal line for every 5 rows in the first page. But in the next page, I can see the horizontal line after 3 rows(and not after 5 rows). This is because of the rows 16,17 in the first group and the rows 18,19,20 in the second group. I want to reset the rownum to zero for the first row of every group.

cities 表:

stateid cid Name

42 52 Memphis

42 56 Nashville

43 49 Arlington

43 54 El Paso

43 4 Houston

43 8 Dallas

43 9 San Antonio

43 15 Austin

43 20 Paso

43 24 Fort Worth

43 72 Corpus Christi

43 78 Plano

43 94 Garland

【回答】

使用报表脚本重置组内序号有点麻烦,这类问题可以通用地在数据源准备阶段用集算器 SPL 加计算列的方式解决:

方法一:在组内每隔 5 行设一个标签



A

1

$select stateid,cid,Name,0 as rowmark from cities

2

>A1.group(stateid).run(~.step(5,5).run(rowmark=1))

结果如下:

1png

方法二:添加组内序号



A

1

$select stateid,cid,Name,0 as rownum from cities

2

>A1.group(stateid).run(~.run(rownum=#))

结果如下:

2png

BIRT 可通过 JDBC 访问集算器,可以像数据库一样使用,参考Java 如何调用 SPL 脚本