A Side-by-side Report with Specified Row Count
【Question】
What can I configure JasperReport detail heapriider layout? I want to print data side by side and every side has 4 data sub bottom.
1 data1 5 data5
2 data2 6 data6
3 data3
4 data4
【Answer】
You can set the column group count for a vertical-orientation report in Jasper. To make each column group have 4 rows in only a certain part of the report, you can convert the source data table to a 4-row, multicolumn table during the data preparation phase. But it’s hard to code the process in either stored procedure or jasper script. Here I choose to express it in esProc SPL (Structured Process Language):
A |
|
1 |
=myDB1.query("select a,b from sorder") |
2 |
=if(A1.len()/Row==0,A1,A1.insert(0:round(A1.len()/Row))) |
3 |
=create(${Col.((t=~,A1.fname().(~+string(t)))).conj().concat@c()}) |
4 |
=A3.record(A1.sort((#-1)%Row).conj([a,b])) |
Row is the row count (here is 4) and Col is the column group count. Both are report parameters. You can use the script to arrange any data table in vertical orientation.
A1: Retrieve data from sorder table.
A2: Divide A1’s record count by 4 and supplement the side with null record if it can’t be full divided.
A3: Build a vertical orientation report structured.
A4: record() function populates data to the side-by-side table.
JasperReport can access an SPL script through esProc JDBC. Details are explained in How to Call an SPL Script in JasperReport.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_SPL
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