Time for action – creating and applying our stylesheet

We will create our own stylesheet using the Style Definition Editor UI, then save it, and look at the XML code that has been created. Then we will assign the stylesheet to our report.

  1. To create our stylesheet, navigate to the option Extras | Style Definition Editor in the upper menu.
  2. Click on the Add Style-Rule option to create a new CSS rule and configure it as follows:
    • Rule= horizontal-line[style-class="Designer"]
    • Style.text-color= #339900

    The CSS rule says that it will apply the style (green color) to all the horizontal lines that have the value Designer in their Attributes.style-class.

    Note

    Designer is the default user used when previewing reports in PRD.

  3. Click on the Add Style-Rule option to create a new CSS rule and configure it as follows:
    • Rule= horizontal-line[style-class="Admin"]
    • Style.text-color= #f02929

    The CSS rule says that it will apply the style (red color) to all the horizontal lines that have the value Admin in their Attributes.style-class.

    Note

    Remember that Admin is the name of a Pentaho BA Server User.

  4. Click on the Add Style-Rule option to create a new CSS Rule and configure it as follows:
    • Rule= report-header label[style-class="Designer"]
    • Style.font-size= 18
    • Style.bold= true

    The CSS Rule says that it will apply the style (large and bold font) to all the labels in the Report Header section that have the value Designer in their Attributes.style-class.

  5. Click on the option Add Style-Rule to create a new CSS rule and configure it as follows:
    • Rule= report-header label[style-class="Admin"]
    • Style.italics= true

    The CSS Rule says that it will apply the style (italic) to all the labels in the Report Header section that have the value Admin in their Attributes.style-class.

  6. Click on the Add Style-Rule option to create a new CSS rule and configure it as follows:
    • Rule= [xml-id="r3_Designer"]
    • Style.visible= false

    This CSS Rule says that it will apply the style (invisible) to the node (section or object) that has the value r3_Designer configured in its Attributes.xml-id.

  7. Save the file. To do so, navigate to the option File | Save As.... Name it styles.prptstyle.
  8. Open the file styles.prptstyle in your favorite text editor. In the part designated for CSS rules we should find something like this:
    <rule>
      <selector>horizontal-line[style-class="Designer"]</selector>
      <styles>
        <content-styles color="#339900"/>
      </styles>
    </rule>
    <rule>
      <selector>horizontal-line[style-class="Admin"]</selector>
      <styles>
        <content-styles color="#f02929"/>
      </styles>
    </rule>
    <rule>
      <selector>report-header label[style-class="Designer"]</selector>
      <styles>
        <content-styles color="#00cc99"/>
        <text-styles bold="true"/>
        <text-styles font-size="18"/>
      </styles>
    </rule>
    <rule>
      <selector>report-header label[style-class="Admin"]</selector>
      <styles>
        <content-styles color="#ff6600"/>
        <text-styles italic="true"/>
      </styles>
    </rule>
    <rule>
      <selector>[xml-id="r3_Designer"]</selector>
      <styles>
        <common-styles visible="false"/>
      </styles>
    </rule>

    Note

    To better understand the code for the <selector> tags, we have replaced the string &quot; with the character ".

    If we pay attention to the XML code, we will see that it is very simple, and with a little practice we can even create our Stylesheets without having to use the PRD UI.

  9. Now we will make a report on our stylesheet. Go to the Structure tab, click on the Master Report node, and in the option Attributes.style-sheet-reference click on the Time for action – creating and applying our stylesheet button. In the window that opens, for Source, search for and choose the stylesheet you just created and select the option Embed in Report as shown in the following screenshot:
    Time for action – creating and applying our stylesheet

What just happened?

We opened the Style Definition Editor UI and using the option Add Style-Rule we added one by one of the CSS rules proposed in the exercise. We created CSS rules that take into account the name of the user who is currently logged in. We created CSS rules for Designer, the PRD default user, and for Admin, a Pentaho BA Server user. Finally, by using Attributes.style-sheet-reference, we assigned the stylesheet we just created to the Master Report node.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset