How to: |
You can use an external cascading style sheet (CSS) to format a report that is generated as HTML, but not one that is generated as a different output type, such as PDF. If you have a report that you will sometimes generate as HTML and sometimes generate as a different output type, and you wish to gain the benefits of cascading style sheets, we recommend that you use this technique:
You can see the basic code for this technique in Use an External CSS With Multiple Output Types.
If you have a report that you will sometimes generate as HTML and sometimes as other types of output, and you wish to gain the benefits of cascading style sheets (CSS), we recommend that you use this technique:
1. -DEFAULTS &FORMAT='output_type'; 2. SET ONLINE-FMT = &FORMAT TABLE FILE datasource report_logic
ON TABLE SET STYLE * 3. TYPE=REPORT, CSSURL = CascadingStyleSheetURL, $ 4. -IF &FORMAT NE 'HTML' GOTO NONHTML; 5. DEFMACRO=macro1, CLASS=class1, $ DEFMACRO=macro2, CLASS=class2, $ . . . 6. TYPE=component3, CLASS=class3, $ . . . 7. -GOTO SHARED 8. -NONHTML 9. DEFMACRO=macro1, attribute1=value1, $ DEFMACRO=macro2, attribute2=value2, $ . . . 10. TYPE=component4, attribute4=value4, $ . . . 11. -SHARED 12. TYPE=component1, MACRO=macro1, $ TYPE=component2, MACRO=macro2, $ . . . ENDSTYLE END
You can use forms and other presentation logic to enable the application user to select the type of report output.
This HTML version of the macros is implemented using external cascading style sheet classes.
This non-HTML version of the macros is implemented using native WebFOCUS StyleSheet attributes.
This report procedure (videorpt.fex) can generate both HTML and PDF output. When it generates HTML output, it uses an external cascading style sheet (reports.css) to format the report. When it generates PDF output, it uses an inline WebFOCUS StyleSheet. In both cases, the report provides a light blue background for the LASTNAME column and makes all column titles bold.
The procedure as shown is set to generate HTML output.
videorpt.fex
1. -DEFAULTS &FORMAT='HTML'; 2. SET CSSURL = http://websrv2/css/reports.css 3. SET ONLINE-FMT = &FORMAT TABLE FILE VIDEOTRK PRINT LASTNAME AS 'Last Name' FIRSTNAME AS 'First Name' BY LOWEST 5 CUSTID AS 'Cust ID' ON TABLE SET PAGE-NUM OFF ON TABLE SET STYLE * 4. -IF &FORMAT NE 'HTML' GOTO NONHTML; 5. DEFMACRO=boldTitles, CLASS=bold, $ DEFMACRO=blueColumn, CLASS=blueBack, $ 6. -GOTO SHARED 7. -NONHTML 8. DEFMACRO=boldTitles, STYLE=bold, $ DEFMACRO=blueColumn, BACKCOLOR=light blue, $ 9. -SHARED 10. TYPE=DATA, COLUMN=LastName, MACRO=blueColumn, $ TYPE=TITLE, MACRO=boldTitles, $ ENDSTYLE END
reports.css
11. .bold {font-weight: bolder} 12. .blueBack {background: lightblue} 13. TABLE {border:0} 13. TD {border:0}
The procedure displays this report: