Formatting a Report With an External Cascading Style Sheet

How to:

Reference:

There are just three items required to format a report with an external Cascading Style Sheet (CSS):

To find out how to use these three items to format a report, see How to Format a Report Using an External Cascading Style Sheet.

For an example that demonstrates how these items work together, see Linking to the ReportStyles External Cascading Style Sheet and the following diagram:


Top of page

x
Procedure: How to Format a Report Using an External Cascading Style Sheet

To format a report using an external Cascading Style Sheet (CSS):

  1. Specify the report formatting in the CSS. Determine which Cascading Style Sheet you will use, which of its rules specify default formatting for your report, and which of its classes are suitable for you to apply to the report components. Alternatively, if you are creating a new CSS, or extending an existing one, define new rules to specify formatting for your report. To specify formatting for:
    • A report component, you can use a rule for any generic class (that is, any class not declared for an element). For an example, see A CSS Rule for the ColumnTitle Class.

      Graphs differ from other types of reports: to specify formatting for the page in which the graph appears, or for the graph heading or footing, you can use a rule for the BODY element, but not a rule for a class. You cannot format other graph components.

    • The entire report, use a rule for the BODY or TD elements (not a rule for a class of these elements), and skip Step 2. This is an effective way of specifying the default formatting of a report, and generates more efficient report output than does applying a CSS class to the entire report. For an example, see A CSS Rule for the TD Element.

      Graphs differ from other types of reports: you can use a rule for the BODY element, but not one for TD. A rule for BODY will format the page in which the graph appears, and its heading and footing, but not the graph itself.

    For more information, see Working With an External Cascading Style Sheet.

  2. Assign classes to report components. In a WebFOCUS StyleSheet, assign a Cascading Style Sheet class to each report component that you want to format. Specify the class using the CLASS attribute. You can assign each component a different class, and you can assign the same class to multiple components.

    For an example, see Applying a CSS Class to ACROSS Values in a Report. For more information, see Applying External Cascading Style Sheet Formatting.

  3. Link to the CSS. Link to the external Cascading Style Sheet by assigning the CSS file URL to either the CSSURL WebFOCUS StyleSheet attribute or to the CSSURL SET parameter. For instructions, see Using the CSSURL Attribute and Parameter.

    There is one exception: if you embed the report output in an existing HTML page using the -HTMLFORM command, include a LINK element in that HTML page instead of setting CSSURL.

    For an example, see Linking to the ReportStyles External Cascading Style Sheet. For more information, see Linking to an External Cascading Style Sheet.

Problems? If you encounter problems, see Troubleshooting External Cascading Style Sheets.


Top of page

x
Reference: A CSS Rule for the ColumnTitle Class

This Cascading Style Sheet (CSS) rule declares the ColumnTitle generic class (that is, a class not tied to an element):

.ColumnTitle {font-family:helvetica; font-weight:bold; color:blue;}

For a more comprehensive example that shows a complete external Cascading Style Sheet, a report procedure with an inline WebFOCUS StyleSheet, and generated report output, see Formatting a Report Using an External CSS.


Top of page

x
Reference: A CSS Rule for the TD Element

This Cascading Style Sheet (CSS) rule for the TD element specifies the element's font family:

TD {font-family:helvetica}

Because this rule is for the TD element, its formatting is applied to an entire report, not just a component of the report.

For a more comprehensive example of using a rule for the TD element to provide general report formatting, see Formatting a Report Using an External CSS.


Top of page

x
Reference: Applying a CSS Class to ACROSS Values in a Report

This WebFOCUSStyleSheet declaration formats ACROSS values by applying the formatting specified for the ColumnTitle class:

TYPE=AcrossValue, CLASS=ColumnTitle, $

For a more comprehensive example that shows a complete external Cascading Style Sheet, a report procedure with an inline WebFOCUS StyleSheet, and generated report output, see Formatting a Report Using an External CSS.


Top of page

x
Reference: Linking to the ReportStyles External Cascading Style Sheet

This WebFOCUSStyleSheet declaration links to the ReportStyles external Cascading Style Sheet:

TYPE=REPORT, CSSURL=http://webserv1/css/reportstyles.css

You could accomplish the same thing using a SET command:

SET CSSURL=http://webserv1/css/reportstyles.css

Alternatively, if you want to embed your report output in an existing HTML page using -HTMLFORM, you would specify the link by coding the LINK element in the HTML page in which the report will be embedded, instead of setting CSSURL:

<HEAD>
<TITLE>Accounts Receivable Report</TITLE>
<LINK REL="STYLESHEET" HREF="http://srv3/css/reports.css" 
TYPE="text/css">
</HEAD>

For a more comprehensive example that shows a complete external Cascading Style Sheet, a report procedure with an inline WebFOCUS StyleSheet, and generated report output, see Formatting a Report Using an External CSS.



Example: Formatting a Report Using an External CSS

This report displays the products currently offered by Gotham Grinds, and is formatted using an external Cascading Style Sheet (CSS). The report is formatted so that:

The report request and inline WebFOCUSStyleSheet are shown in the following procedure, curprods.fex. The external Cascading Style Sheet, named report01.css, follows the procedure.

curprods.fex

    TABLE FILE GGPRODS
    HEADING
    "</1 Current Products</1"
    PRINT PRODUCT_DESCRIPTION UNIT_PRICE
    BY PRODUCT_ID
    ON TABLE SET PAGE-NUM OFF 
    
1.  ON TABLE SET STYLE * 
2.  TYPE=REPORT, CSSURL=http://websrv2/css/report01.css, $ 
3.  TYPE=HEADING, CLASS=headText, $ 
4.  TYPE=TITLE, CLASS=reportTitles, $ 
5.  TYPE=DATA, CLASS=lowCost, WHEN=N3 LT 27, $ 
6.  ENDSTYLE
    END

report01.css

7.  BODY  {font-family:Arial, sans-serif} 
8.  TABLE {border:0} 
8.  TD    {border:0} 
9.  .reportTitles {font-weight:bolder; background:lightblue;} 
10. .lowCost {color:green; font-style:italic;} 
11. .headText {font-family:Times New Roman, serif; font-size:larger;
               text-align:center}
  1. Begin the inline WebFOCUS StyleSheet.
  2. Link to the external Cascading Style Sheet, report01.css.
  3. Format the report heading using the Cascading Style Sheet rule for the headText class.
  4. Format the report column titles using the CSS rule for the reportTitles class.
  5. For each report row for which the product unit cost is less than $27, format that row using the CSS rule for the lowCost class.
  6. End the inline WebFOCUS StyleSheet.
  7. This CSS rule for the BODY element specifies the font family Arial and, if Arial is unavailable, the generic font family sans serif.

    Because this is a rule for BODY, it is applied to the entire report: all text in the report will default to Arial. You can override this for a particular report component by applying a rule for a generic class to that component, as is done in this procedure with the rule for the headText class (see line 11).

  8. These CSS rules for the TABLE and TD elements remove the report default grid.
  9. This CSS rule for the generic class reportTitles specifies a bolder relative font weight and a light blue background color.

    The WebFOCUS StyleSheet applies this to the report column titles (see line 4).

  10. This CSS rule for the generic class lowCost specifies the text color green and the font style italic.

    The WebFOCUSStyleSheet applies this rule conditionally to report rows for which the product unit cost is less than $27 (see line 5).

  11. The CSS rule for the generic class headText specifies the font family Times New Roman and, if Times New Roman is unavailable, the generic font family serif. It also specifies a larger relative font size and center justification.

    The WebFOCUSStyleSheet applies this rule to the report heading. It overrides the default font family specified in the rule for the BODY element (see line 7).

The procedure displays this report:


WebFOCUS