Building a reporting application
An application that generates a report must complete the required tasks described in the following sections. Additional tasks, such as supplying user‑entered values for parameters, are optional.
Creating and configuring a report engine
A single report engine object can generate multiple reports from multiple report designs. Use the Platform.createFactoryObject( ) method to create a ReportEngine object. For OSGi, set the BIRT home directory in the BIRT_HOME environment variable, which defines the location of required plug-ins and libraries.
Opening a report design or report document
Use one of the openReportDesign( ) methods of the ReportEngine class to open a report design from a String file name or an input stream. These methods return an IReportRunnable object.
Use the openReportDocument( ) method of the ReportEngine class to open a report document (.rptdocument) file from a String file name. This method returns an IReportDocument object.
Ensuring access to the data source
Ensure the report engine can locate the classes that connect to the data source and supply data to the data set. The report engine can either create a connection to the data source or use a Connection object that the application provides.
Preparing to create a report in the supported output formats
Use an IRenderOption object to set the output format, the output file name or stream, the locale, and format-specific settings. The HTMLRenderOption class supports the HTML output format. For PDF output, use PDFRenderOption.
Generating a report in one of the supported output formats
Use an IRunAndRenderTask object to create the report from the IReportRunnable object. Use an IRenderTask object to create the report from an IReportDocument object.
Alternatively, use a URL to access the report viewer servlet, such as when deploying a BIRT report to an application server, as described earlier. The report viewer can generate a report from either a design or a document file.
Destroying the engine
Destroy the report engine after the application has generated all required reports.
Optional tasks
The tasks in the following list are optional for a reporting application. Typically, the application performs one or more of these tasks.
*Gather values for parameters.
If the application uses a report design that has parameters, use the default values for the parameters or set different values.
*Create a report document file.
A report document file contains the report in a binary storage form. If the application uses a report design, use an IRunTask object to create the report document as an IReportDocument object.
*Export data from a report document.
Use an IDataExtractionTask object to extract data values from any item or set of items in the report document. Export the data values to a file or another application, or perform further processing on the data.