Add HtmlComponent to JasperDesign

0

Through various searches on the internet I found how to use the HtmlComponent in my project to have an HTML-table in my report (as an image).

However, I can't seem to find how I can add the HtmlComponent to a JasperDesign.

Versions in use:

  • Jasper 5.6.1
  • HtmlComponent 5.0.1 (derived from iReport 5.6.0).

My current code:

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;

Obviously, groupHeader.addElement(table) doesn't work since table is not an element but a component.

Anyone and idea?

valentin.gregoire's picture
Joined: Mar 2 2017 - 8:38am
Last seen: 3 years 5 months ago

3 Answers:

0

Since I wasn't expecting as much action here as on StackOverflow, I posed my question there as well. The answer to my problem is written there:

http://stackoverflow.com/questions/42560528/how-to-add-the-htmlcomponent...

valentin.gregoire's picture
Joined: Mar 2 2017 - 8:38am
Last seen: 3 years 5 months ago
0

This isn't a direct answer to your question but

HTML Component is obsolete. Use Custom Visualization component instead. It allows to use svg.

hozawa's picture
64268
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 year 2 months ago
0

hozawa, is that supported through jasper 5.6.1?

EDIT: I found something interesting here: http://community.jaspersoft.com/wiki/custom-visualization-component-jasp...

I am not sure however if it will be usable.

valentin.gregoire's picture
Joined: Mar 2 2017 - 8:38am
Last seen: 3 years 5 months ago
Feedback
randomness