I’ve seen several questions lately on how to use the BIRT CSV Emitter example that is explained in the Integrating and Extending BIRT book. While the book goes into great detail explaining what each file does and even how to build the entire example yourself, my blog post will just give the basic steps necessary to use the example. The steps below assume you have an Eclipse IDE and have also downloaded the BIRT Runtime engine.
First we need to download the example CSV emitter project and the associated classes used to run the example. You can find the files at this link. You will need both org.eclipse.birt.report.engine.emitter.csv.zip and ExecuteCSVReport.zip from the Report rendering section.
Next, we need to import the files into Eclipse.
- From the Eclipse IDE, select Import from the File menu and then select Existing Projects into Workspace under General and press Next.
- Select org.eclipse.birt.report.engine.emitter.csv.zip as the archive file and then make sure the project displayed is checked before pressing Finish.
- Repeat these steps to import the project from ExecuteCSVReport.zip. Don’t worry about any reference errors in the project at this time… we’ll correct those later.
Now that our projects are imported, we need to export the CSV emitter plug-in.
- Right-click on the org.eclipse.birt.report.engine.emitter.csv project and select Export.
- Choose Deployable plug-ins and fragments from the Plug-In Development choices and press Next.
- Make sure your plug-in is selected and then choose your ReportEngine directory that is part of your BIRT Runtime Engine download.
Now that our new plug-in is exported, we need to test it. The ExecuteCSVReport project contains an example report and code we can use for this test but first we need to fix the project references to point to our own BIRT Runtime Engine files.
- Right-click the ExecuteCSVReport project and select Properties.
- Select Java Build Path and then Libraries
- Highlight all the JAR files that indicate they are missing and press the Remove button.
- Press the Add External JARs button and select all the files from your ReportEngine/lib directory.
- Press the Add External JARs button again and this time select the new plug in you just created. If you accepted the defaults from the export step above, then this should be in the ReportEngine/plugins directory in a file called org.eclipse.birt.report.engine.emitter.csv_1.0.0.jar.
Now that our project references are corrected, we need to correct one more reference in our ExecuteReport.java file that points to the BIRT Runtime Engine.
- Double-click ExecuteReport.java to open this file in the editor.
- Change the setEngineHome line to point to your ReportEngine directory like the example shows below.
config.setEngineHome( “C:/work/eclipse/BIRT_230/birt-runtime-2_3_0/ReportEngine” )
Once the ExecuteReport.java file is saved we can run the example.
- Right click on ExecuteReport.java and select Run As | Java Application. You will see a message that says “We are done!!!” in the Console if everything worked correctly.
- Press F5 on your ExecuteCSVReport project to refresh the files and you should now see a new file called csvReport.csv in the reports folder.