Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Extract database information using Eclipse and BIRT V2.0

Design dynamic reports, charts, and templates

Scott Delap (scott@clientjava.com), Desktop/Enterprise Java Consultant
Scott Delap is an independent consultant specializing in Java EE and rich Java clients. He has presented papers at JavaOne and is actively involved in the desktop Java community. He is also the administrator of ClientJava.com, a portal focused on desktop Java development. ClientJava.com is frequently featured all over the Web, from JavaBlogs to Sun Microsystems' Web site.
Robert Thornton (ret1@acm.org), Java Consultant, Daugherty Business Solutions
Robert Thornton has been developing in the Java language for six years and is currently a consultant for Daugherty Business Solutions. He works as a developer and architect on Java EE applications at various clients in the St. Louis, Mo., area. He has a strong focus on object-oriented development and works primarily in the Java and C++ languages.

Summary:  The Eclipse Business Intelligence and Reporting Tools (BIRT) project comprises a set of open source plug-ins for Eclipse that you can use to create compelling reports for Web applications. Learn how to install BIRT V2.0, configure it for use with a database, employ its functionality to design dynamic reports and charts, and create templates for future reports.

Date:  25 Apr 2006
Level:  Intermediate PDF:  A4 and Letter (394 KB | 27 pages)Get Adobe® Reader®

Activity:  16000 views
Comments:  

Customization

Now that you've created a basic dynamic report, you need to clean it up and provide polish so it looks professional. Some simple changes can help you get to that point.

Format numbering

To format the numbering in the table, select the salary cell and the salary footer in the table. (Select multiple objects by pressing Ctrl and clicking the objects.). Now, complete these steps:

  1. Open the Property Editor.
  2. In the Properties pane, click Format Number.
  3. Select Currency from the Format Number as drop-down list, then change the symbol to be the dollar sign ($).
  4. Select the Use 1000s separator check box.
  5. Click General in the Properties pane, and make the column right-justified instead of left. Right-justify the header and footer for that column, as well.

Filter information

Another customization you might consider is to hide the chief executive officer's (CEO's) salary. To do so, complete these steps:

  1. Highlight the SALARY cell and switch to the Property Editor.
  2. Click Visibility in the Properties pane and select the Hide Element check box.
  3. Select the For specific outputs option.
  4. Select the HTML check box.
  5. Click the ... button to build the expression.
  6. Type the expression row["LASTNAME"] == 'Conrad' to filter out the CEO's salary, then click OK.
  7. Select the PDF check box, and type the same expression there. If you don't select this check box, the CEO's salary would be hidden when the report was viewed as a Web page, but not when a PDF was generated. Your report should now appear similar to Figure 8.

Figure 8. Report with the CEO salary filtered
Report with the CEO salary filtered

A better solution is to add the Title column from the database to the Employee Salaries data set:

  1. Right-click Employee Salaries in the Data Explorer and click Edit.
  2. Add the Title column to the select clause.
    Note that the order of the fields in the select clause doesn't matter.
  3. Click OK, then go back to the Property Explorer visibility section and change the expression to row["TITLE"] == 'CEO'. Now any employee with the title of CEO will have her salary hidden on this report.

Distinguish certain employees

The next step in customizing this report is to distinguish people from the sales department. You can do this in any of several ways. A couple of options are to add the department field to the Employee Salaries data set and change the sort criteria for the table to sort first by department. Alternatively, you could provide some type of color-coding to the report.

For this report, leave the sorting by last name intact. Instead, change the report to italicize all the salespeople's names. Go back into the Employee Salaries data set and add the Department column to the select clause, just as you just did for the title. Now, change the row of the table to look different depending on which department the employee is in.

To edit the properties for a row, you must select the detail row. Hover your mouse over the table and click the Table tab that appears. Doing so brings up the outline for the table so you can click the entire row, as shown in Figure 9.


Figure 9. Selecting the entire row
Selecting the entire row

With that row highlighted, complete these steps:

  1. Open the Property Editor and click the Highlights tab.
  2. Click Add and click the ... button at the top.
  3. Use the Expression Builder to create the expression row["DEPARTMENT"] and click OK.
  4. Select Equal from the second list and type "Sales" in the third box. Make sure that you include the quotation marks in the field. In this way, you can change the format of the row for all rows where the employee is in the Sales department.
  5. Change the font, size, and color of the text for that row. Set the font to Arial, blue, and italics.
  6. Click OK, and preview the report. It should look similar to Figure 10.

Figure 10. Report with the sales rows highlighted
Report with sales rows highlighted

Report parameters

What if my company has a large number of employees? You need to be able to allow management or human resources to pull up just one individual's information. You can use Report Parameters to limit the results shown to the user. With Report Parameters, you can prompt the user for information before the report is run. In this case, you'll prompt users to select a name:

  1. Right-click Report Parameters in the Data Explorer and click New Cascading Parameter.
  2. Change the name to EmployeeName and click Create New.
  3. Name the data set EmployeeName, and type the query SELECT lastname, firstname FROM employees.
  4. Click OK.
  5. Select the new data set from the Data Set list.
  6. Double-click the first row of the Value column in the grid below and select last name.
  7. Double-click the Display Text column and select the same.
  8. In the Properties area, name the parameter Last name and set the prompt text to Enter last name of employee.
  9. In the second row, do the same with the name First name, then click OK.

Now you need to tell the table to filter the results based on those parameters:

  1. Select the table, switch to the Property Editor, then click the Filters tab.
  2. Click Add in the upper-right corner of the tab.
  3. Double-click the Expression column of the new filter criteria and switch to the Expression Editor.
  4. Use the Category and Sub-Category to highlight your new Report Parameter group, then double-click Last name. When you click OK, the Expression column should read params["Last name"].
  5. Click in the Value 1 column and select build expression and LASTNAME from the data set. Click OK. That cell should read row["LASTNAME"].
  6. Add another filter criterion and set it for first name.
  7. Right-click your report in the Navigator and click Run Report.

You'll be prompted to type a last name and first name for the employee you want to see. When you type a last name, BIRT restricts the list of first names from which you can select to only those where the last name matches your selection. You can also use the Preview window to see the results of this, but BIRT won't always prompt you to type the parameter values. In the upper-left corner of the Preview window, click Show Report Parameters to specify new values to preview with.

4 of 9 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source, Information Management
ArticleID=109241
TutorialTitle=Extract database information using Eclipse and BIRT V2.0
publish-date=04252006
author1-email=scott@clientjava.com
author1-email-cc=
author2-email=ret1@acm.org
author2-email-cc=