3 min read

Stylesheets

BIRT, being a web-based reporting environment, takes a page from general web development toolkits by importing stylesheets. However, BIRT stylesheets function slightly differently to regular stylesheets in a web development environment.

We are going to add on to the Customer Orders report we have been working with, and will create some styles that will be used in this report.

  1. Open Customer Order.rptDesign.
  2. Right-click on the getCustomerInformation dataset and choose Insert into Layout.
  3. Modify the table visually to look like the next figure.

    Use of Stylesheets for Report Designing using BIRT

    Create a new dataset called getCustomerOrders using the following query: //insert code 1

  4. Link the dataset parameter to rprmCustomerID.
  5. Save the dataset, right-click on it, and select Insert to layout.

    Use of Stylesheets for Report Designing using BIRT

  6. Select the first ORDERNUMBER column.

    Use of Stylesheets for Report Designing using BIRT

  7. Under the Property Editor, Select Advanced.

    Use of Stylesheets for Report Designing using BIRT

  8. In the Property Editor, go to the Suppress duplicates option, and change it to true. This will prevent the OrderNumber data item from repeating the value it displays down the page.

    Use of Stylesheets for Report Designing using BIRT

  9. In the Outline, right-click on Styles and choose New Style….

    Use of Stylesheets for Report Designing using BIRT

  10. In the Pre-Defined Style drop down, choose table-header. A predefined style is an element that is already defined in the BIRT report. When selecting a predefined style, this will affect every element of that type within a report. In this case, for every table in the report, the table header will have this style applied.

    Use of Stylesheets for Report Designing using BIRT

  11. Under the Font section, apply the following settings:
    • Font: Sans-Serif
    • Font Color: White
    • Size: Large
    • Weight: Bold
  12. Under the Background section, set the Background Color to >b>Black.
  13. Click OK.

Now, when we run the report, we can see that the header line is formatted with a black background and white font.

Use of Stylesheets for Report Designing using BIRT

Custom stylesheets

In the example we just saw, we didn’t have to apply this style to any element, it was automatically applied to the header of the order details table as it was using a predefined style. This would be the case for any table that had the header row populated with something and the same is the case for any of the predefined styles in BIRT. So next, let’s look at a custom defined style and apply it to our customer information table.

  1. Right-click on the Styles section under the Outline tab and create a new style.

    Use of Stylesheets for Report Designing using BIRT

  2. Under the Custom Style textbox, enter CustomerHeaderInfo.

    Use of Stylesheets for Report Designing using BIRT

  3. Under the Font section, enter the following information:
    • Font: Sans Serif
    • Color: White
    • Size: Large
    • Weight: Bold
  4. Under the Background section, set the Background Color to Gray.
  5. Under the Box section, enter 1 points for all sections.
  6. Under the Border section, enter the following information:
    • Style (All): Solid
    • Color (All): White
    • Width (All): Thin
  7. Click OK and then click Save.
  8. Select the table which contains the customer information.

    Use of Stylesheets for Report Designing using BIRT

  9. Select the first column.

    Use of Stylesheets for Report Designing using BIRT

  10. Under the Property Editor, in the list box for the Styles, select CustomerHeaderInfo.
    Use of Stylesheets for Report Designing using BIRT
  11. The preview report will look like the following screenshot:
    Use of Stylesheets for Report Designing using BIRT
  12. Right-click on the Styles section, and create a new custom style called CustomerHeaderData.

    Use of Stylesheets for Report Designing using BIRT

  13. Under Box, put in 1 points for all fields.
  14. Under Border, enter the following information:
    • Style – Top: Solid
    • Style – Bottom: Solid
    • Color (All): Gray
  15. Click OK.
  16. Select the Customer Information table.

    Use of Stylesheets for Report Designing using BIRT

  17. Select the second column.

    Use of Stylesheets for Report Designing using BIRT

  18. Right-click on the column selector and select Style | Apply Style | CustomHeaderData.
  19. The finished report should look something like the next screenshot:

    Use of Stylesheets for Report Designing using BIRT


Subscribe to the weekly Packt Hub newsletter

* indicates required

LEAVE A REPLY

Please enter your comment!
Please enter your name here