I managed to add the HtmlComponent
to my project through various searches.
My next problem is that I don't have a clue how to add it to a JasperDesign
.
I simply can't find any way to add my HtmlComponent
to a JasperDesign
(not even through a group etc).
I use Jasper 5.6.1 and managed to get the HtmlComponent jar (5.0.1) out of the iReport tool (5.6.0).
My end purpose is to be able to have an HTML-table inside my report. I know it's not possible in any way, but perhaps, an HTML-component would be the most interesting thing. This way, an image of the table would be in my report, which is ok.
This is my current code
private JasperDesign getTable(String html, JasperDesign jasperDesign) {
HtmlComponent table = new HtmlComponent();
JRDesignExpression expression = new JRDesignExpression();
expression.setText(html.replace("\n", ""));
table.setHtmlContentExpression(expression);
JRDesignGroup group = new JRDesignGroup();
group.setName(TABLE_GROUP_PREFIX);
JRDesignBand groupHeader = new JRDesignBand();
groupHeader.setHeight(200);
groupHeader.setSplitType(SplitTypeEnum.IMMEDIATE);
groupHeader.addElement(table);
((JRDesignSection) group.getGroupHeaderSection()).addBand(groupHeader);
return jasperDesign;
}
The line groupHeader.addElement(table)
fails because HtmlComponent is not an Element, but a Component.