How can I add dynamic columns to jasper report?

0

I want to adding dynamic columns to my select statement. Is it possible? If not can I achieve this with Jasper report? Which tool I have to use in JasperReport? Please help me. I am adding my current table and the wanted table.

My table:


order_id              product_id           alternative_id
 1                          12                 15
 1                          12                 16
 1                          12                 17
 1                          13  
 1                          14  
 2                          18                 19
 2                          20                 21
 2                          20                 22
 2                          23  
 2                          24                 25

I wanted to create this table in jasper report. Is it possible?

order_id    product_id  alternative_id1    alternative_id2   alternative_id3
   1            12         15                 16                 17
   1            13          
   1            14          
   2            18         19       
   2            20         21                 22    
   2            23          

willywonka15's picture
Joined: Aug 21 2017 - 6:39am
Last seen: 1 year 4 months ago

3 Answers:

0

you can dynamically display columns using the "table" component, but I think you have to know the names of all potentially displayed columns in advance, and account for them all in the jrxml. IF that's your case, then the table component will work, and it can optionally display a subset of those available columns. otherwise, you'll have to use a programmatic approach with jasper via java, or alternatively you can generate dynamic jrxml using apache velocity.

this reference is dated but the solution is still valid:

http://thinkinginsoftware.blogspot.com/2011/06/ireport-dynamically-hide-...

darth_fader's picture
Joined: Mar 7 2010 - 9:45pm
Last seen: 1 month 1 day ago
0

Are you using Adhoc Views? If so, you can add selectable columns dynamically.

Sample of adding columns dynamically (add new column around 55 seconds)

https://www.youtube.com/watch?v=bXD1HBZzA14

 

If you're using Jaspersoft Studio, try using crosstab component.

https://community.jaspersoft.com/documentation/tibco-jaspersoft-studio-u...

hozawa's picture
44169
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 month 5 days ago
0

Hi,

I have the same problem.

Can anyone explain how to do this with crosstab in JasperStudio?

Panzer's picture
2
Joined: Aug 16 2018 - 10:52am
Last seen: 11 months 3 days ago
Feedback
randomness