Sunday, March 12, 2006

XLS(MS Excel) Emitter for BIRT

For those who wanted an xls emitter for a long time, finally here may be a chance to taste. Thanks the Apache POI project and the new layout engine of BIRT 2.0, now we can easily create an xls emitter though it looks obviously not that fancy yet.

To install and use:

1. Install and run Birt correctly first. Since various api changed between 2.0RC and release version in birt engine, This plugin will only work with BIRT 2.0.0/2.0.1 final release(You need to download corresponding packages).

2. Extract the downloaded plugin file into the eclipse plugins directory.

3. Download Apahce POI library from apache site, put it in the /lib directory under the extracted xls plugin folder. You must donwload the latest 3.0 dev version, since the 2.5 release version doesn’t support the image output. A tested and recommended version is poi-3.0-alpha1-20050704.jar.

4. Download and apply the chart&designer&viewer patch file so to make the xls plugin work correctly both in the designer and viewer. If you are building BIRT from a CVS source tree, override the soure file; if you are just using the binary BIRT sdk, replace the class files in related plugin jar. Here is the list:

org.eclipse.birt.chart.reportitem org\eclipse\birt\chart\reportitem\ChartReportItemPresentationImpl in plugins/org.eclipse.birt.chart.reportitem_2.0.x/reportitem.jar

org.eclipse.birt.report.designer.ui org\eclipse\birt\report\designer\ui\actions\PreviewToolbarMenuAction in plugins/org.eclipse.birt.report.designer.ui_2.0.x/ui.jar

org.eclipse.birt.report.viewer org\eclipse\birt\report\viewer\aggregation\layout\EngineFragment in plugins/org.eclipse.birt.report.viewer_2.0.x/birt/WEB-INF/lib/viewservlets.jar

Though only three files are involved, this is just to make the designer/viewer simply work with the xls emitter. So the xls option will only appear in the preview toolbar action, sure you can apply your own patch to make it visible in the File menu as well.

5. Ok, now create a report as usual and choose preview as XLS, enjoy:)

Both binary and source are available now:).

For BIRT2.0.0
Download binary: http://qauck.host.sk/xls-emitter.zip
Download source: http://qauck.host.sk/xls-emitter-src.zip

For BIRT2.0.1
Download binary: http://qauck.host.sk/xls-emitter-bin_2.0.1.zip
Download source: http://qauck.host.sk/xls-emitter-src_2.0.1.zip

(If you have problem downloading the above files, try right click the link and select "save target as..." or use some web proxies.)

XLS Emitter patch for BIRT2.1

Since BIRT2.1 layout api changed, I updated the source code to make it work with the 2.1 version. Note this will make it no longer compatible with BIRT2.0, and because BIRT2.1 is not formally released yet, this patch is just experimental and subject to change.

Download patch: http://qauck.host.sk/xls-emitter_2.1patch.zip

Integrate XLS emitter with standalone Java applications

Since many people asked how to integrate the XLS emitter with standalone java applications or servlet environtment, I investigated a little on this.

Unfortunately, Current BIRT framework can't handle the new OSGi form plugins when running in a standalone mode(e.g. not in eclipse workbench/rcp). So the resolution is just to downgrade the plugin manifest file to the old style plugin.xml.

For testing, I used an handy report framework introduced by Mark Lorenz, and everything looks fine.

The example just shows how to integrate the emitter with a standard file ouput. To support servlet environment, you can simply redirect the output to an OutputStream and specify a proper mime type ("application/vnd.ms-excel" for this case). The birt newsgroup already hosts a lot discussions on how to integrate birt with the servlet environment.

Download integration example: http://qauck.host.sk/standalone-integration.zip

Google