Ir al contenido principal

Reporte Excel con JasperReports

Pues no funcionó el reporte con Jasper, pude hacer que evitara paginar con estas opciones

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
JRXlsExporter exporterXLS = new JRXlsExporter();
exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
// exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IGNORE_PAGE_MARGINS, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, byteArrayOutputStream);
try {
exporterXLS.exportReport();
} catch (JRException ex) {
Logger.getLogger(ReporteAction.class.getName()).log(Level.SEVERE, "No se pudo crear el excel", ex);
}
getResponse().setContentType("application/vnd.ms-excel");
getResponse().setContentLength(byteArrayOutputStream.toByteArray().length);
getResponse().setHeader("Content-disposition",
"attachment; filename=\"" + reportName + ".xls\"");
ServletOutputStream out;
try {
out = getResponse().getOutputStream();
out.write(byteArrayOutputStream.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}

y con una archivo jasperreports.properties
#net.sf.jasperreports.query.executer.factory.sql=com.jaspersoft.jasperserver.api.engine.jasperreports.util.JRTimezoneJdbcQueryExecuterFactory

#limit the crosstab bucket/measure count to prevent out of memory errors
#net.sf.jasperreports.crosstab.bucket.measure.limit=100000

# suppress page headers and footers when exporting to XLS
net.sf.jasperreports.export.exclude.origin.band.1=pageHeader
net.sf.jasperreports.export.exclude.origin.band.2=pageFooter

# this gets rid of the repeating column headers and footers in excel exports
net.sf.jasperreports.export.xls.exclude.origin.band.1=columnHeader
net.sf.jasperreports.export.xls.exclude.origin.band.2=pageFooter

# keep the first column header on export
net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.1=columnHeader

# report exporter hints override export parameters
net.sf.jasperreports.export.parameters.override.report.hints=false

# use the workaround for the Sun JDK Glyph synchronization bug
net.sf.jasperreports.text.measurer.factory=net.sf.jasperreports.engine.util.JdkGlyphFixTextMeasurerFactory

# the fast/single line text measurer factory
net.sf.jasperreports.text.measurer.factory.single.line=com.jaspersoft.jasperserver.api.engine.jasperreports.util.SingleLineTextMeasurerFactory

# other excel options
#net.sf.jasperreports.export.xls.remove.empty.space.between.rows=true
#net.sf.jasperreports.export.xls.remove.empty.space.between.columns=true
#net.sf.jasperreports.export.xls.detect.cell.type=true
#net.sf.jasperreports.export.xls.create.custom.palette=true

Pero no me sirve de nada porque tengo un listado de 1500 y a partir del 600 se hace bolas y empieza poner campos donde no van, y a omitir otros, ademas algunos objetos como que su descripción no cabe y lo pasa a otro renglón, se ve bien, pero los datos no los voy a poder actualizar nuevamente de ahí, porque voy a tener campos sin id, y datos incompletos en el renglón... de plano no sirve... Ya sabía eso antes de empezar, pero realmente pensé que después de unos años, ya lo hubieran arreglado... pero bueno, voy a hacerlo con POI... seguramente tendré un mejor final, y más vale que me apure, pues todavía no preparo la demo de mañana.

Comentarios

Entradas más populares de este blog

Tomcat Cluster en Debian 7 (Wheezy)

Pues nos hemos animado a crear un cluster de tomcat. La verdad es muy sencillo hacerlo, simplemente habilitas unas opciones que ya vienen en tomcat y configuras mod_jk en apache para que administre el cluster y haga el balanceo de cargas. Muy, muy fácil, el detalle está en que no tienes alta disponibilidad, razón por la que puse el cluster en primer lugar. ¿Y entonces? Pues me puse a investigar, ya probé LiveRebel, y funciona de maravilla, pero igual te cobran... Así que busqué un poco más y di con mod_cluster de RedHat. Esta herramienta te permite lo mismo que mod_jk, pero le agrega alta disponibilidad, ¿a qué me refiero con alta disponibilidad? Al hecho de que cuando hay que hacer un redeploy de la aplicación si estas con mod_jk, apache no va a darse cuenta y te va a seguir enviando al tomcat que está haciendo el redeploy, y el cliente recibe el error de que no hay nada ahí, lo que sí hace mod_jk es notar que una instancia de tomcat ha sido dada de baja, entonces para lograr alta d...

Opensolaris vs Ubuntu vs Windows 7

Pues como ya les había mencionado, estuve probando OpenSolaris 2008/11... No puedo decir que ha sido una mala experiencia, simplemente no puedo producir tanto como produzco en windows como ubuntu. Ahora bien, es una plataforma sólida con todo lo que tienen los servidores que están en producción en muchas empresas, y con una interfaz gráfica bastante útil y fácil de usar si has usado Gnome antes. La cuestión está que todavía no es tan rápido como windows y menos como ubuntu. Le falta todavía en el área de multimedia y en la usabilidad de ciertas cosas, por ejemplo el trackpad, no toma los puntos donde puedes hacer scroll, no puedes utilizar la cámara, no tiene suspender ni hibernación. Además le toma un buen iniciar, no tanto como el 2008/5, pero igual, le toma mucho... Dadas esas circunstancias terminé en Windows 7... pero igual, carece de un ambiente al que ya me acostumbré bastante, las "ventanas" donde puedes agrupar el trabajo... Mejoró en su barra de tareas, donde se ase...