Passing many datasets to jasper reports

Questions and answers on developing, deploying and using plugins and JavaBeans

Passing many datasets to jasper reports

Postby wvitpr » Sun Mar 06, 2022 4:05 pm

Hello,
I have a dashboard in my solution with a few powergrids on the one form, I have been asked to create a simple pdf of the same to send as email. The querys are all different and quite complex and I would prefer not to recreate the sql in Jasper Reports, can I pass the datasets as parameters and then use them in my report somehow?
Regards,
Phillip Routley

Worldview IT
Sydney, Australia
User avatar
wvitpr
 
Posts: 219
Joined: Tue Apr 24, 2007 1:38 am

Re: Passing many datasets to jasper reports

Postby ptalbot » Mon Mar 07, 2022 5:28 pm

Don't know about jasper, but in Velocity you can pass as many datasources (datasets, foundsets, arrays, objects) as you want in a context simply putting them all in the context object:

Code: Select all
var context = { fs1: aFoundset, fs2: anotherFoundset, ds: aDataSet, ds2: anotherDataSet, array: anArray, obj: anObject, etc... };
var pdf = plugins.VelocityReport.getPDFReport(template, context);


Then in your html template you use #foreach or $ object notation (and . notation for related values) to output the data.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: Passing many datasets to jasper reports

Postby omar » Mon Mar 07, 2022 5:59 pm

wvitpr wrote:Hello,
I have a dashboard in my solution with a few powergrids on the one form, I have been asked to create a simple pdf of the same to send as email. The querys are all different and quite complex and I would prefer not to recreate the sql in Jasper Reports, can I pass the datasets as parameters and then use them in my report somehow?


Hi,

Yes you can. In this case you would create a subreport for each powergrid and pass the corresponding datasets in as a parameter which is then passed in to the subform. It's a bit of struggle to get it right the first time but after that it's a piece of cake.

Kind regards,
Intrasoft, Founder
Omar van Galen
omar@intrasoft.nl
+31-(0)6-21234586
Servoy Developer
omar
 
Posts: 377
Joined: Sat Feb 12, 2011 4:51 pm
Location: Intrasoft, The Netherlands


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 10 guests