11/26/11

Merge multiple Jasper Reports in to Single Report

If you are working with Jasper Reports and JAVA you should meet with this problem


[jasperreports-questions] Merge multiple JasperPrint Objects

jeipack
Mon, 16 Apr 2007 04:55:31 -0700
Hi
I just want to show several JasperPrint Objects in only one JRViewer. Is
there a function to concat 2 or more JasperPrint Objects to one JasperPrint
Object? or something like that?

In pseudo code:
JasperPrint jp1 = JasperFillManager.fillReport(url.openStream(), parameters,
                    new JRBeanCollectionDataSource(inspBean));
JasperPrint jp2 = JasperFillManager.fillReport(url.openStream(), parameters,
                    new JRBeanCollectionDataSource(inspBean));
JasperPrint jp = jp1+jp2

jrviewer= new JRViewer(jp);


I hope its clear what i mean.
Thanks for your help!
jeipack




http://www.mail-archive.com/jasperreports-questions@lists.sourceforge.net/msg00728.html

a slimier question is [update] http://stackoverflow.com/questions/2666001/how-to-merge-two-pdf-documents-into-a-single-report-in-jasperreports/8278526#8278526

unfortunately the solution is build a sub report and use the 2 different DataSource or what ever connection you used



but there is an easy way to get over with this question :D
just simple no new reports ..... Wolaah

ok lets do it

JasperPrint jp1 = JasperFillManager.fillReport(url.openStream(), parameters,
                    new JRBeanCollectionDataSource(inspBean));
JasperPrint jp2 = JasperFillManager.fillReport(url.openStream(), parameters,
                    new JRBeanCollectionDataSource(inspBean));


ok we have over 2 records ..lets take our first record  jp1 and add jp2 content into it
  
List pages = jp2 .getPages();
            for (int j = 0; j < pages.size(); j++) {
            JRPrintPage object = (JRPrintPage)pages.get(j);
            jp1.addPage(object);
        
    }
    JasperViewer.viewReport(jp1,false);


This work like a charm .. with couple of loops you can merge any number of report together .. without creating new reports  

Questions are welcome