I'd like to create a dynamic reporting webpage using JSP. Basically it should contain the following parts:
- Filter: The user can specify the filter conditions and press a filter button.
- HTML-output: The result of the filter can be seen here. It's one large html page (or several if one page would be too large). It may contain links to other parts of the system.
- PDF-output: The user should be able to save a pdf version of the report for printing or archiving purposes.
Instead of implementing everything myself, I'd like to use a java reporting library, so I created my report using JasperReports. The pdf output is really nice, but the html export of the report is not suitable for my purposes.
JasperReport's html export creates an html file with lots of hardwired code, and quite random configuration options. For instance it creates a table with white background by default (<table style="... bgcolor="white" ... ">
) which can be turned off using IS_WHITE_PAGE_BACKGROUND
option, on the other hand cellpadding="0" cellspacing="0" border="0"
are hardwired in the table
tag. It is also strange (and makes css styling difficult) that instead of span classes the html file contains <span style="font-family: sansserif; color: #000000; font-size: 10.0px;">
for all my fields.
Of course I can implement the html-output using JSP, but it means I have to design the output twice (once in jrxml for JasperReports, once in JSP), and I have to reimplement reporting functions (like subtotal calculation, total calculation, grouping ...) which is against the DRY principle.
What is the best practice for implementing this? Is it possible to create a better HTML export using JasperReports?