Reference: |
Each report component inherits StyleSheet attributes from its parent component. You can override an inherited attribute by explicitly specifying the same attribute with a different value in the declaration for the child component. Since each component inherits automatically, you need specify only those attributes that differ from, or that augment, the inherited attributes of a component.
Inheritance enables you to define common formatting in a single declaration, and to apply it automatically to all child components, except for those components for which you specify different attribute values to override the inherited values. You benefit from less coding and a more concise StyleSheet.
For example, you could specify that all report titles should be blue and bold:
TYPE=TITLE, COLOR=BLUE, STYLE=BOLD, $
Each column title will inherit this formatting, appearing in blue and bold by default. However, you can choose to format one column differently, allowing it to inherit the blue color, but specifying that it override the bold style and that it add a yellow background color:
TYPE=TITLE, COLUMN=N2, STYLE=-BOLD, BACKCOLOR=YELLOW, $
Report components inherit StyleSheet attributes according to a hierarchy. The root of the hierarchy is the entire report, specified in a StyleSheet declaration by TYPE=REPORT. Declarations that omit TYPE default to TYPE=REPORT and are also applied to the entire report. Attributes that are unspecified for the entire report default to values that are determined according to the display format of the report, such as HTML or PDF.
Each report component inherits from its parent component. Component X is a parent of component Y if X is specified by a subset of all the "type" attributes that specify Y, and if those shared type attributes have the same values. For example,
For example, in the following syntax, by defining specific styling for the column at the DATA level, the overall style from TYPE=REPORT will be applied (FONT=TAHOMA), but not TYPE=REPORT, COLUMN=N2 (COLOR=GREEN). To apply the color green to the data in column 2, you have to explicitly make it green.
TYPE=REPORT, FONT=TAHOMA, $ TYPE=REPORT, COLUMN=N2, COLOR=GREEN, $ TYPE=DATA, COLUMN=N2, STYLE=+UNDERLINE+BOLD, $
When you use an external cascading style sheet (CSS), a report component inherits formatting from parent HTML elements, not from a parent report component. For more information, see Inheritance and External Cascading Style Sheets.
The following illustrates how to augment inherited StyleSheet attributes. The StyleSheet declarations discussed in this example are highlighted in the report request.
The page heading in this report has two lines. The first StyleSheet declaration identifies the report component HEADING to be formatted in bold and have 12-point font size. This will format both lines of the heading with these styles.
To augment the format for the second line of the heading, a second declaration has been added that specifies the heading line number and the additional style characteristic. In this case we have added the declaration TYPE=HEADING, LINE=2, STYLE=ITALIC. The second line of the heading will inherit the bold style and 12-point font size from the first HEADING declaration, and will also receive the italic style defined in the second declaration.
TABLE FILE GGSALES SUM UNITS DOLLARS BY CATEGORY BY PRODUCT HEADING "Sales Report:" "First Quarter" ON TABLE SET PAGE-NUM OFF ON TABLE SET STYLE * TYPE=REPORT, GRID=OFF, $ TYPE=HEADING, STYLE=BOLD, SIZE=12, $ TYPE=HEADING, LINE=2, STYLE=ITALIC, $ ENDSTYLE END
The output is:
The following illustrates how to override StyleSheet inheritance. The StyleSheet declarations discussed in this example are highlighted in the report request.
TABLE FILE GGSALES HEADING "Sales Report" SUM UNITS DOLLARS BY CATEGORY BY PRODUCT BY DATE NOPRINT WHERE DATE GE 19960101 AND DATE LE 19960401 ON TABLE SET STYLEMODE PAGED ON TABLE SET LINES 20 FOOTING "Page <TABPAGENO of <TABLASTPAGE" ON TABLE SET STYLE * TYPE=REPORT, GRID=OFF, $ 1. TYPE=REPORT, BACKCOLOR=BLUE, COLOR=WHITE, $ 2. TYPE=HEADING, BACKCOLOR=WHITE, COLOR=BLACK, STYLE=BOLD, SIZE=12, $ 3. TYPE=FOOTING, SIZE=11, STYLE=BOLD+ITALIC, BACKCOLOR=WHITE, COLOR=BLACK, $ 4. TYPE=FOOTING, OBJECT=FIELD, ITEM=1, STYLE=-ITALIC, $ ENDSTYLE END
The output is: