Output a Side-by-side Table
【Question】
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
Each employee detail 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
A solution:
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)
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?
【Answer】
To output a side-by-side table in BIRT, try configuring the columns property on master page tab. A safer and more universal way is to prepare the source data in the specified format with esProc SPL (Structured Process Language). That is, group data every 24 rows (a page height) and compose a new 4-column data set (two groups per page) and then present it in the report without splitting data in column groups. Below is the SPL script:
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 is the row count per page; Col is the column group count (here the value is 2). Both are report parameters. You can split any table in the side-by-side format.
A1: Retrieve data from sorder table.
A2: Build the table in a side-by-side format.
A3: run() function populates data to table in the side-by-side format.
esProc functions like a database. BIRT can call the SPL script via esProc JDBC. Detailed explanation can be found in How to Call an SPL Script in Java.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL