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 it adds the style tag to the generated HTML with the CSS attributes defined. This will set the border-collapse CSS property to collapse for all tables in the generated HTML.

Fork me on GitHub