Reputation: 27
I have some information in an HTML file. There are more HTML files, which all contains strings which depends on an input parameter(bold).
as an Example:
file_**01**.html --> contains: "Bob Bakers"
file_**02**.html --> contains: "Alice Armstrong"
The HTML files are stored in the repository and I would like to import/load the content of one of these files into a textfield. With some images I've done something similia like:
"repo:/home/res/images/" + $F{html_param} + ".html"
And depending on the parameter, it loads the right image. I need to do the same with the strings from the HTML files.
If it is not possible to do this with an Text Field, are there other options to import/load the content and show them in the report?
Upvotes: 0
Views: 843
Reputation: 5093
You can do something like this
<textField>
<reportElement .../>
<textElement markup="html"/>
<textFieldExpression>new String(net.sf.jasperreports.repo.RepositoryUtil.getInstance($P{JASPER_REPORTS_CONTEXT}).getBytesFromLocation("repo:/home/res/images/" + $F{html_param} + ".html"), java.nio.charset.StandardCharsets.UTF_8)</textFieldExpression>
</textField>
This would work as long as the html file structure is simple, otherwise markup="html"
might fail to interpret the document.
Upvotes: 2