Archive

Posts Tagged ‘BIRT-Viewer’

Combine Multiple BIRT Designs To Generate Single Report

September 18, 2010 1 comment

We use BIRT for generating reports in our application. Currently we have a suite of report designs that covers various parts of the application. Reports are generated on demand by the user. The application required the functionality of specifying a list of birt rpt design files, which can then be run to generate a single report for the user.

It is quite common to have the need to run several reports and then render them all into one report. In practice, this could be achieved by the ability to merge multiple rpt design files to one, or have IReportEngine.createRenderTask method to take an array of IReportDocuments instead of just one. BIRT does not have support for this functionality yet. Have a look at the issue here.

We went ahead to implement this functionality by following approach of running multiple reports and then to combine their output to a single report. We found that it is not very difficult to do so.

Let’s have a look at MergeReportsPDF code listing. It has a main method which after retrieving a list of file paths of rpt design files makes a call to merge them in a single pdf report. If you look closely at the runReport method you will notice that it first initializes the BIRT engine and then loops into the list of file paths to run BIRT task. The runReport method also accumulates this into a list of ByterArrayOutputStream which is then used later to render a combined pdf report using itext. The method renderCombinedReportFromOutputStreams constructs PdfCopyFields with destination FileOutputStream parameter; it then reads in the BIRT report output one by one to construct a list of PdfReader object. Finally it loops in the list of pdfReader to construct a pdf report.
Read more…

Categories: Java Tags: ,

Using Scripted Data-Sources in BIRT and Deploying in Application Server

September 12, 2010 Comments off

We have been working on requirement of rendering a complex financial report for users of our web-application and also offering the possibility to export the HTML report in PDF format. We decided to use BIRT for the purpose because of its rich capabilities in terms of design and layout along with its out-of-the box offering for exporting the generated report in different formats like PDF, PS, Excel etc. Along with this functional requirement, we also wanted to use pre-populated Java Object graph as Data-Source for our report. In this post, I would like to talk about two things:

  • How to Use Java Objects as Data Source for BIRT Report
  • How to package everything and deploy in an Application Server

Using Java Objects as Data Source for BIRT Report

While working on different type of reporting tools, the often used approach is to fetch data from underlying Database through JDBC Data-Sources and then use the output of corresponding Data-Sets for rendering different parts of the report in form of tables, charts, cross-tabs etc. In our case, the complexity was that data set is quite big and generally comes from multiple sources like different Databases, Web-Services and others. If we want to achieve the same inside BIRT, first, it might get quite complicated if not just impossible and secondly we might suffer from serious performance issues in terms of time required to render the complete report. So we decided to do this information gathering work in an earlier step and then use a pre-populated Java Object graph as an already complete Data-Source for our report. This also allowed us to re-use our existing components and domain classes and not duplicate/re-write code specifically for report designing.
Read more…