I apologize about all the time I was away from here. I am having a busy time with a couple of huge projects around me...
This post is just to tell people I am alive (:P) and to share a very simple and useful way to generate pdf reports using Jasper Reports.
File jsFile = new File("path_to_jasper_file");
Map parm = new HashMap(); //parms to be "sent" to report. You can use null, if you want
JRBeanCollectionDataSource jrBeanSource = new JRBeanCollectionDataSource("a collection here"); //argument is not a string...it is a bean collection
JasperRunManager.runReportToPdfFile(jsFile, "path_to_pdf_to_be_created", parm, jrBeanSource);
In this case, I am using a collection of beans as data source. Could be any other source supported by Jasper. Oh, don't forget exceptions handling.
See you soon (I hope...)
0 comments:
Post a Comment