InetSoft Documentation: Exporting Dashboards and Reports to HTML

HTMLGenerator is used to export a report in HTML format. If the report contains images, the images can be converted to JPEG or PNG format. It is also possible to create an HTML bundle. In this case, the HTML and related images are bundled together into a zip file.

View 2-min Dashboard Demo
Register for Pricing
#1 Ranking: Read how InetSoft was rated #1 for user adoption in G2's user survey-based index Read More

Exporting a Report to HTML Format

For Web-based applications, HTML has become a popular way to present reports. While it is straightforward to generate text-based HTML directly, adding other elements, such as charts, to HTML is not as easy. The HTML exporting feature in InetSoft products allows a regular report to be converted to HTML with almost no extra coding, so you can build one report and have an option to present/print it with the InetSoft classes or send it to a browser as an HTML file.

The HTML exporting facility uses only the basic HTML commands in HTML 3.0. This ensures compatibility with as many browser versions as possible. Because HTML does not have many of the formatting capabilities that Style Intelligence has, the generated HTML may lose some formatting information that is in the actual report.

As part of the HTML generation process, the builder may need to generate additional files that are used inside the HTML file. This is true for any non-text elements, such as charts, images, etc…

 FileOutputStream os = new FileOutputStream(filename);
 Builder builder = Builder.getBuilder(Builder.HTML, os, ".");
 builder.write(sheet);
 os.close(); 

While the Builder can be used to get the appropriate Builder for HTML generation, the HTMLGenerator performs the generation and is found in the inetsoft.report.io package.

Image Files

The extra parameter in the getBuilder() call specifies the directory in which to place the additional image files. If it is omitted, it defaults to the current directory. Image files are produced as PNG or JPEG files. PNG images are smaller in file size and are often of better quality than JPEG, however PNG is only supported by version 4.0 browsers and higher.

 ReportEnv.setProperty("image.type", "png");
 //or
 ReportEnv.setProperty("image.type", "jpeg"); 

If an image element in the report uses a URL for image location, no image file will be generated. Instead, the specified URL is placed in the generated HTML as the image location.

Exporting an HTML

Bundle An HTML Bundle consists of a zip file, which contains the generated HTML report as well as all associated image files. To generate an HTML Bundle, first create an OutputStream, which will be used by the Builder. The next step is to get the Builder to generate the HTML Bundle.

FileOutputStream os = new FileOutputStream(filename); 
Builder builder = Builder.get
Builder(Builder.HTML_BUNDLE, os, ".");
builder.write(sheet); 

The HTML Bundle is generated by the Builder class using the inetsoft.report.io.HTMLFormatter. The Builder seamlessly takes care of writing to the ZipOutputStream. Setting the property on ReportEnv as described above also controls the type of image file, JPEG or PNG.

Setting the DHTML Meta-Data Information

DHTML meta-data can be set for a ReportSheet before exporting the report to HTML. The following properties may be set:

report.title
report.subject
report.author
report.keywords
report.comments
report.created
report.modified

The properties can be set in the following way:

 ReportSheet report = new TabularSheet();
 report.setProperty("report.title", "Hello");
Previous: Exporting Dashboards and Reports to Excel