1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
@RequestMapping(value="/report1",method=RequestMethod.GET)
@ResponseBody
public void report1(HttpServletResponse response) {
InputStream jasperStream=this.getClass().getResourceAsStream("/reports/report1.jrxml");
JasperDesign design=JRXmlLoader.load(jasperStream);
JasperReport report=JasperCompileManager.compileReport(design);
Map<String, Object> params=new HashMap<String, Object>();
List<Incident> incidents=incidentRepository.findAll();
JRDataSource jRDataSource=new JRBeanCollectionDataSource(incidents);
params.put("dataSource", jRDataSource);
JasperPrint jasperPrint=JasperFillManager.fillReport(report,params,jRDataSource);
response.setHeader("Content-Disposition", "inline ; filename=insidents.pdf");
final OutputStream outputStream=response.getOutputStream();
JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream);
}catch(JRException ex){
log.info("erreur de reporting");
} catch(IOException e){
log.info("********");
}
} |
Partager