对记录做横向分栏

【问题】

Hi i have a single list of employees. Each employee will have his name and salary.

i have given the list of employees to a table but it appears as follows

Employee Name            Salary

harish                    3000

kiran                     4000

Emili                     6000

harsha                    7000

vardhana                  8000

siri                      9000

i mean each employee details appears in a single row . but i want them to appear side by side on the same page as shown below.

EmployeeName1        Salary1          EmployeeName2            Salary2

harish               3000             kiran                        4000

Emili                6000            harsha                     7000

vardhana            8000             siri                        9000

----- 技术支持给的解法:代码实现

on table one filtering, the following code is written

pageBreakInterval = 21;

blockNumber = Math.floor(row.__rownum / pageBreakInterval) + 1;

totalColumns = 3;

columnNumber = 1;

((blockNumber - columnNumber) >= 0)&& (((blockNumber - columnNumber) % totalColumns)== 0)

on table-2 filter the following code is written

pageBreakInterval = 21;

blockNumber = Math.floor(row.__rownum / pageBreakInterval) + 1;

totalColumns = 3;

columnNumber = 2;

((blockNumber - columnNumber) >= 0)&& (((blockNumber - columnNumber) % totalColumns)== 0)

on table-3 filter the following code is written

pageBreakInterval = 21;

blockNumber = Math.floor(row.__rownum / pageBreakInterval) + 1;

totalColumns = 3;

columnNumber = 3;

((blockNumber - columnNumber) >= 0)&& (((blockNumber - columnNumber) % totalColumns)== 0)

hi with the above code in 3 table filters i guess the first table will be filled with first 21 records and the next 21 records will be filled in the second table and the next to next 21 records will be filled in the third table. Is this right?

【回答】

BIRT 分栏打印的功能,具体在 master page 标签页的 columns 属性,可以试一下。如果这种方法无效,则可以用集算器准备好已分栏后的数据:将源数据每 24 行(一页纸的高度)分为一组,拼成 4 列的新数据集(每页 2 组)。然后作为不分栏的表呈现即可,可以通用地解决这个问题。SPL 代码如下:



A

1

=myDB1.query("select EmployeeName,Salary from sorder")

2

=create(${Col.((t=~,A1.fname().(~+string(t)))).conj().concat@c()})

3

>Row.run(A2.record(A1.m(to(Col*(~-1)+1,Col*~)).conj(~.array())))

Row 是每页行数,Col 是分栏数,都是报表参数,可以将任意表进行分栏(将 Col 固定为 2 即是你的要求)。

A1:查询 sorder 表

1png

A2:生成分栏表结构

2png

A3:使用 run 函数为分栏后的表填入数据

3png

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