Guardar un reporte en formato pdf
Publicado por Paulinas (4 intervenciones) el 27/08/2015 00:51:49
Hola si me podrian ayudar con un reporte se abre correctamente el reporte al ejecutar la aplicacion, pero deseo guardarlo en formato pdf ... y se me guarda como un html este es mi codigo;
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
35
36
37
38
39
public void reporte_calificaciones(String calificacion) {
try {
listadatoscalificacion = DatosCalificacionAcciones.Obtener_calificaciones(ocatevc.getIdcategoria(), calificacion, fechadesde, fechahasta, objperfil, dm.getSesionFuncionActual());
// listadatoscalificacion = DatosCalificacionAcciones.Obtener_calificaciones(128, calificacion, fechadesde, fechahasta);
Reporte datasource = new Reporte();
if (!listadatoscalificacion.isEmpty()) {
for (DatosCalificacion datevc : listadatoscalificacion) {
Dato d = new Dato(
datevc.getIdticket(),
PerfilServicios.ObtenerPerfilDadoCodigo(datevc.getIdcreador(), dm.getSesionPerfilActual(), dm.getSesionFuncionActual()).getStralias(),
datevc.getAsunto(),
datevc.getSolucion(),
datevc.getFecha_llegada(),
datevc.getHora_llegada(),
datevc.getFecha_solucion(),
datevc.getHora_solucion(),
datevc.getCalificacion()
);
datasource.addParticipante(d);
}
JasperReport reporte = (JasperReport) JRLoader.loadObject(Metodos_Reportes.getAbsolutePath("report1.jasper"));
JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, null, datasource);
HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream();
JRExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, servletOutputStream);
exporter.exportReport();
} else {
Util.addErrorMessage("No tiene evaluaciones de este tipo");
}
} catch (Exception e) {
}
}
Valora esta pregunta


0