Categories: TutorialsData

Use of Stylesheets for Report Designing using BIRT

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.

    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.

  6. Select the first ORDERNUMBER column.

  7. Under the Property Editor, Select Advanced.

  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.

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

  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.

  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.

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.

  2. Under the Custom Style textbox, enter CustomerHeaderInfo.

  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.

  9. Select the first column.

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

  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.

  17. Select the second column.

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

Packt

Share
Published by
Packt

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago