Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Embedding external html file(s) in report
mvid
Hi!
I have to import an external HTML file into a BIRT report. This is not a static text - one portal generates these HTML files, and another generates reports, which should load a certain HTML into a text field at the end of a report. The exchange through a DB is not possible. I believe I cannot deliver this through the file data source, because it is not a proper flat file format. Just a regular text with usual formatting.
The report can take a link to the HTML file as a URL or as a path to the file, because both systems have access to the same storage. One HTML per report.
I'm aware that I shoult implement OnCreate or OnPrepare Event of the text field, but I'm not very handy with scripting within Birt reports. What's the easiest way to do this?
Thanks!
Find more posts tagged with
Comments
mvid
To answer myself...<br />
<br />
1) define a str parameter called "htmlfile" (it should contain the file name + path)<br />
<br />
2) put a text field on the form and define html formatting for it<br />
<br />
3) put following script in this field's onCreate event:<br />
<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage( Packages.java.io );
var fileasstr = "";
var tmpstr = "";
//read file path from the supplied parameter
filename = reportContext.getParameterValue("htmlfile")
filereader = new FileReader(filename );
buffreader = new BufferedReader( filereader );
// serialize opened file
while((tmpstr = buffreader.readLine()) != null) {
fileasstr+=tmpstr;
}
// close file handles
buffreader.close();
filereader.close();
// and add it to the text field
this.text = fileasstr;
</pre>