iReport 多个报表组成一个PDF

//在jsp页面中

<%

//new 一个 ArrayList集合 把 要显示的JasperPrint 放进去
  ArrayList jasperPrintList = new ArrayList();
   JasperPrint jasperPrintArr = JasperFillManager.fillReport ("reportAva.jasper",  new HashMap(), new AvaDataSource());  
   JasperPrint jasperPrintCpu = JasperFillManager.fillReport ("cpuIReport.jasper",  new HashMap(), new CpuDatasource());  
   JasperPrint jasperPrintFan = JasperFillManager.fillReport ("FanReport.jasper",  new HashMap(), new FanDatasource());
   JasperPrint jasperPrintLinAva = JasperFillManager.fillReport ("LinAvaReport1.jasper",  new HashMap(), new LinDatasource());
   JasperPrint jasperPrintLinDis = JasperFillManager.fillReport ("LinDisReport.jasper",  new HashMap(), new LinDisDatasource());
   JasperPrint jasperPrintMemory = JasperFillManager.fillReport ("MemoryReport.jasper",  new HashMap(), new MemoryDatasource());
   JasperPrint jasperPrintPower = JasperFillManager.fillReport ("PowerReport.jasper",  new HashMap(), new powerDatasource());
   JasperPrint jasperPrintTpt = JasperFillManager.fillReport ("TptReport.jasper",  new HashMap(), new TptDatasource());
   JasperPrint jasperPrintVol = JasperFillManager.fillReport ("VolReport.jasper",  new HashMap(), new VolDatasource());
   JasperPrint jasperPrintTile = JasperFillManager.fillReport ("Title_report.jasper",  new HashMap(), new VolDatasource());
   jasperPrintList.add(jasperPrintTile);
   jasperPrintList.add(jasperPrintArr);
   jasperPrintList.add(jasperPrintCpu);
   jasperPrintList.add(jasperPrintLinAva);
   jasperPrintList.add(jasperPrintMemory);
   jasperPrintList.add(jasperPrintLinDis);
   jasperPrintList.add(jasperPrintFan);
   jasperPrintList.add(jasperPrintVol);
   jasperPrintList.add(jasperPrintPower);
   jasperPrintList.add(jasperPrintTpt);
   
  //报表编译之后生成的.jasper 文件的存放位置
   //传递报表中用到的参数值

  Map parameters = new HashMap();  
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   JRPdfExporter exporter = new JRPdfExporter();
   exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST,jasperPrintList);
   exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
  
   exporter.exportReport();
   byte[] bytes= baos.toByteArray();//得到这个流
  
  System.out.println("---------Jasper end-------------");
   response.setContentType("application/pdf");
   response.setContentLength(bytes.length);
   ServletOutputStream ouputStream = response.getOutputStream();
   ouputStream.write(bytes, 0, bytes.length);
   ouputStream.flush();
   ouputStream.close();
%>

<html>
  <head>
  </head>
  
  <body>
    
   </body>
</html>

 转载于good_dou的专栏http://hi.csdn.net/link.php?url=http://blog.csdn.net%2Fgood_dou

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值