Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create dynamic columns in JRxml file for jasper report generation? [duplicate]

I have a set to data to be shown in a tabular format using jasper report and currently writing the .jrxml file.

In my dataset, i have data which will serve us to know number of columns for the table, hereby making it dynamic columns for table.

So, the issue is Data fetched from database is row specific; so how can i make it work to convert it to no of columns for table?

I have a dB table from where data is pulled up:

TEST_ID   LEVEL   LOT_NUM  MEAN          UNITS       PERCENT            
--------- ------  -------- ------------- ----------- -------------
GLU       1       1212     2.1             10           22                     
GLU       2       1314     3.2             10           22                     
GLU       3       1414     3.3             10           22       

I have to create the report likewise:

TEST_ID   LEVEL:1  LEVEL:2   LEVEL:3  UNITS PERCENT
-------   -------  -------   -------  ----- -------
GLU       2.1      3.2       3.3      10    22

-: Number of LEVEL's becomes the number of columns for particular tests.

like image 874
GOK Avatar asked Nov 01 '12 09:11

GOK


1 Answers

Your use case looks like your columns can only be identified at run time. For such use cases,you can look at either of two libraries - dynamic jasper and dynamic reports. I have seen more usage of dynamic jasper over dynamic reports though.

like image 136
Cshah Avatar answered Oct 14 '22 08:10

Cshah