Bonjour,
j'ai le besoin de générais le .jaspr en temps réel avec la génération du document (bien sûr en utilisant le .jrxml).
Comment je eux faire ça en java ? (quel changement je doit faire si ça existe)
voilà mon code qui permet la génération de document.
Merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 public void init() throws JRException { try { JasperCompileManager.compileReportToFile(pathJrxml); File reportFile = new File(pathJasper); JRBeanCollectionDataSource beanCollectionDataSource = new JRBeanCollectionDataSource(listOfDataTable); jasperPrint = JasperFillManager.fillReport(reportFile.getAbsolutePath(), new HashMap(), beanCollectionDataSource); } catch (Exception e) { JsfUtil.addWarningMessage("Forte chance que les Chemeins d'un des fichise de jasperreports n'est pas Bon. !!"); Logger.getLogger(Ireport.class.getName()).log(Level.SEVERE, e.toString()); } } /** * Méthode réutilisable pour l'exportation de document en format PDF. * * @param actionEvent * @throws JRException * @throws IOException */ public void PDF(ActionEvent actionEvent) throws JRException, IOException { init(); try { HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse(); httpServletResponse.addHeader("Content-disposition", "attachment; filename=report.pdf"); ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream(); JasperExportManager.exportReportToPdfStream(jasperPrint, servletOutputStream); } catch (Exception e) { JsfUtil.addWarningMessage("Le document est corrompu ou mal télécharger... !!"); Logger.getLogger(Ireport.class.getName()).log(Level.SEVERE, e.toString()); } finally { } }
Partager