Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
594 views
in Technique[技术] by (71.8m points)

jasper reports - How do I add a second page in Jaspersoft iReport Designer 4.7

Hello I'm completely new to using Jaspersoft iReport Designer. I want to have a report with two pages. The version I'm using is 4.7.0. I already have one page with information on it but I have no clue how to add a second page. Any help will be appreciated. Thank you for your time.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can accomplish this a couple ways.

  • The first is actually creating 2 separate reports and merging them. Basically you draw out each page how you want it to look. On export, you create the 2 JasperPrint instances of the report, and then batch export them.

    public byte[] generateReport(JasperPrint jasperPrint1, JasperPrint jasperPrint2) {
      //throw the JasperPrint Objects in a list
      List<JasperPrint> jasperPrintList = new ArrayList<JasperPrint>();
      jasperPrintList,add(jasperPrint1);
      jasperPrintList,add(jasperPrint2);
    
    
      ByteArrayOutputStream baos = new ByteArrayOutputStream();     
      JRPdfExporter exporter = new JRPdfExporter();     
      //Add the list as a Parameter
      exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
      //this will make a bookmark in the exported PDF for each of the reports
      exporter.setParameter(JRPdfExporterParameter.IS_CREATING_BATCH_MODE_BOOKMARKS, Boolean.TRUE);
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);       
      exporter.exportReport();      
      return baos.toByteArray();
    }
    
  • The second option is to go the Subreport route. Basically you create the first page of the report. Then you create the second page of the report. Then in iReport you can add the subreport in to Summary Band, passing any needed information that it needs to run (i.e Database Connection, datasource, parameters, etc.). Under the properties for the overall report you will want to make sure Summary on new page is selected so that the the subreport will print on its own page.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...