HOW-TO Use Virtualizers

Report Virtualization is a mechanism JasperReport introduced in order to make possible huge report generation Through different strategies (GZip compression in memory, using a file swap, etc.) they save a lot of memory. Virtualizers a used exclusively by JasperReports at report fill time, we’ll just briefly show here how to use them. Actually there are…

HOW-TO Tricks when exporting to HTML

Collapsing table borders This How-to is possible thanks to Dipesh This is a work-around to avoid “double-border” effect when rendering html tables. The trick is to add some CSS directives in the rendered html through the JRHtmlExporterParameter.HTML_HEADER JRHtmlExporter exporter = new JRHtmlExporter(); exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, “<style>table{border-collapse:collapse}</style>”); // Set your other exporter parameters here What this does is…

HOW-TO Export to HTML

In your web.xml declare ImageServlet (from JasperReports) to allow images in the report to be shown properly. <servlet> <servlet-name>image</servlet-name> <servlet-class>net.sf.jasperreports.j2ee.servlets.ImageServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>image</servlet-name> <url-pattern>/reports/image/*</url-pattern> </servlet-mapping> Later in a Servlet or so use the DJServletHelper class which handles the most common scenario for HTML exporting in a HTTP web server. DJServletHelper will directly write the HTML…

HOW-TO Create a clean Excel report

DynamicJasper is a useful tool when creating plain Excel sheets. The only difference with regular reports, is that we have to use the ListLayoutManager class instead of the ClassicLayoutManager. This is because the former layout manager prevents JasperReport to leave blank spaces or have miss aligned cells. You can still use the ClassicLayoutManager when generating…