Respuestas de la comunidad Computrachos.com
Deja tu Respuesta
Disculpa, debes iniciar sesión para escribir un comentario.
Bienvenid@, Visitante! [ Registrarte| Iniciar Sesion ]
Disculpa, debes iniciar sesión para escribir un comentario.
Alguien?
Fue útil la respuesta?
LikeDislikeEl método para abrir un reporte desde JAVA
try { JasperReport masterReport = null; try { URL urlMaestro = getClass().getResource("/Reportes/"+nombre+".jasper"); //System.out.println(urlMaestro.toString()); masterReport = (JasperReport) JRLoader.loadObject(urlMaestro); } catch (JRException ex) { Logger.getLogger(Cargardor_Reportes.class.getName()).log(Level.SEVERE, null, ex); } Map masterParams = new HashMap(); for(int para=0;para<parametros.length;para++) { masterParams.put(etiquetas[para],parametros[para]); } JasperPrint masterPrint = null; try { conexion=new Conecta(); masterPrint = JasperFillManager.fillReport(masterReport, masterParams, conexion.con); JRExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, masterPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE, new java.io.File("reportePDF.pdf")); exporter.exportReport(); } catch (JRException ex) { Logger.getLogger(Cargardor_Reportes.class.getName()).log(Level.SEVERE, null, ex); } JasperViewer jviewer = new JasperViewer(masterPrint,false); if(masterPrint.getPages().isEmpty()==false) { jviewer.setVisible(true); } else { JOptionPane.showMessageDialog(null,"Reporte No Tiene Paginas"); conexion.con.close(); } } catch (SQLException t) { JOptionPane.showMessageDialog(null,"No Se Puede Mostrar: " + t.getMessage(),"Mensaje de Error", JOptionPane.ERROR_MESSAGE,new ImageIcon(getClass().getResource("/resources/ok_no.png"))); }Fue útil la respuesta?
LikeDislike