BIRT 横向分栏

【问题】

I have a table which will displays User ids in one column. I want to display that column as two columns

Ex. In First Row, First user id in Column 1 and Second user id in Column2,

      In Second Row,  second user id in Column 1 and third user id in Column2,

    In Third row, third user id in Column 1 and fourth user id in Column2,

1jpg

【回答】

实现方法大都要使用行间计算,用报表脚本或 SQL 实现起来太复杂。这种情况下用集算器辅助 BIRT 准备分栏数据更方便,代码如下:



A

1

=db.query("select col1 from sorder")

2

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

3

=A2.record(A1.conj([~[-1],~]).to(3,).(#1))

A1:查询初始表

1png

A2:生成分栏表结构

2png

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

3png

BIRT 可以通过 JDBC 连接集算器,调用脚本方法和调用存储过程一样,详情参考【BIRT 调用 SPL 脚本​】。