任务:将Jasper报告(确切地说是JasperPrint的一个实例)导出为嵌入了图表图像的HTML .
目前工作解决方案:
private byte[] getHtmlReport(JasperPrint abstractFilledReport) throws JRException {
HtmlExporter exporter = new HtmlExporter();
ByteArrayOutputStream out = new ByteArrayOutputStream();
// Configure exporters IO
exporter.setExporterInput(new SimpleExporterInput(abstractFilledReport));
exporter.setExporterOutput(new SimpleHtmlExporterOutput(out));
writeHtmlReport(abstractFilledReport);
EmbeddedHtmlConfiguration exporConfig = new EmbeddedHtmlConfiguration();
exporter.setConfiguration(exporConfig);
// Write report to OutputStream
exporter.exportReport();
return out.toByteArray();
}
static class EmbeddedHtmlConfiguration extends SimpleHtmlReportConfiguration{
@Override
public
Boolean isEmbedImage(){
return Boolean.valueOf(true);
}
}
问题:除了编写一个额外的类来调整一个属性外,还有更优雅的方法吗?