Creating reports with BIRT

Business Intelligence and Reporting Tools (BIRT) is an Eclipse-based reporting system that allows for sophisticated output in PDF or HTML format, including graphics, tables, graphs, and charts. EGL support for BIRT is available when you code programs generated for Java.

You can begin designing your output by opening the Report Design perspective of the Workbench and creating a Report project. Alternatively, you can do all your work in an EGL or web project.

You create a report, which (in the context of your output-design work) is an XML file whose default extension is .rptdesign. The steps are as follows:
  1. Click File or right click on the project
  2. Select New > Other
  3. At the Select a Wizard dialog, choose Business Intelligence and Reporting Tools > Report
  4. Specify a parent folder and report name, and click Next
  5. At the New Report dialog, select a template that will be the basis of your report. Help is available if you press the question icon, and details on report design will be displayed subsequently if you check Show Report Creation Cheat Sheet.
  6. Click Finish.
  7. Your subsequent tasks include specifying a data source (for example, a JDBC connection), specifying a data set (for example, the database columns specified in an SQL SELECT statement), and using a palette to drag and drop elements such as labels and tables. You can rely on the cheat sheet and can get a fuller introduction to report design by accessing the tutorial and background detail at the following website:

      https://eclipse.github.io/birt-website/

Working at the EGL or web perspective, you create EGL code that drives output creation. The creation can have two steps:
  1. The report (hereafter called the design file) is converted to a second file, called a document file, which has a default extension of .rptdocument and contains data in an intermediate format
  2. The document file is converted to the PDF or HTML output
Two other choices are possible, to speed processing:
  • You can skip the creation of a separate document file
  • You can start the process with an existing document file instead of a design file
The basic idea for working with BIRT in EGL is as follows:
  • You create an EGL BIRT report, which is a variable based on BIRTReport, an external type. You can include various details (name of a design file, for example) when declaring that variable, or you can avoid specifying some or all of the details and add them later by invoking functions or setting fields that are specific to the EGL BIRT report. In either case, you can specify the details at development time, by using literals, or at run time, by using variables.
    Here's an example of the syntax that first creates an EGL BIRT report and then specifies the fully qualified name of the design file:
      myReport BIRTReport { };
      myReport.designFile = "C:/MyBIRTReport.rptdesign";
  • You invoke a function that creates the output, as in the following example:
      myReport.createReportFromDesign();
    The following creation functions are available:
    • createReportFromDesign() creates output from a design file, without storing the report data in a document file
    • createReportFromDocument() creates output from a document file
    • createDocument() creates a document file from a design file
  • You can create an EGL report handler of type BIRTHandler. This optional logic part contains functions that act as event handlers, allowing you to customize many details that affect the report output. When EGL is creating a report document (as is possible with createDocument or createReportFromDesign), the EGL runtime code invokes the event handlers in response to the following events, among others:
    • The opening or closing of a text file or database connection
    • The opening or closing of a database cursor
    • The retrieving of a row of database data into report fields
    • The creation of a report element such as a label or grid
    An event handler might (for example) accomplish one of the following tasks:
    • Specify the value of a report parameter that guides some aspect of report processing
    • Specify a user ID and password for connecting to a database
    • Set up an SQL SELECT statement to guide data retrieval from the database
    • Act as an intermediary, receiving displayable data from your EGL program and then providing that data to the report engine at the appropriate time
    • Change report formatting and text in response to a specific value being placed into the report

You can use a cascading style sheet (CSS) to control display characteristics of the report.