Exporting to HTML generates the following:
The HTML_HEADER
parameter of JRHtmlExporterParameter was replaced with:
HtmlExporterConfiguration.getHtmlHeader()
For example:
public byte[] exportHtml(final JasperPrint print) {
final Exporter exporter = new HtmlExporter();
final ByteArrayOutputStream out = new ByteArrayOutputStream();
exporter.setConfiguration(createHtmlConfiguration());
exporter.setExporterOutput(new SimpleHtmlExporterOutput(out));
exporter.setExporterInput(new SimpleExporterInput(print));
exporter.exportReport();
return out.toByteArray();
}
private HtmlExporterConfiguration createHtmlConfiguration()
throws IOException {
SimpleHtmlExporterConfiguration shec
= new SimpleHtmlExporterConfiguration();
shec.setHtmlHeader(getHtmlHeader());
shec.setHtmlFooter(getHtmlFooter());
return shec;
}
private String getHtmlHeader() {
StringBuffer sb = new StringBuffer();
sb.append("");
sb.append("");
sb.append(" ");
sb.append(" ");
sb.append(" ");
sb.append("");
sb.append("");
sb.append("");
sb.append("");
return sb.toString();
}
private String getHtmlFooter() {
// Close the opening tags from getHtmlHeader()...
}
Even better would be to use external resources (such as a database, file, or web page) for the HTML content, rather than hard-coded strings.
讨论(0)
- 热议问题