Styling Reports With StyleSheets

In this section:

To use a StyleSheet, follow these steps:

  1. Decide which StyleSheet to use. If one already exists with the formatting you need, go on to the next step. FOCUS comes with default styles that you can use if you want the whole report printed with the same default format. If you want to customize certain formats in your report, create a StyleSheet that describes those formats.

    Note: You can change some formatting features, such as the page parameters, with a SET command without creating a StyleSheet.

  2. Activate the StyleSheet you have chosen, or create a StyleSheet in a report request.
  3. Create a PostScript, HTML, PDF (Acrobat's Portable Document Format), Excel 2000, or Excel 97 file that contains the formatted report.

    Use FTP to transfer this file to Windows, if necessary.

  4. Print the report on a PostScript printer or open it in the appropriate application. This step is highly dependent on the equipment and software at your site. See your system administrator for instructions.

Top of page

x
What Is a StyleSheet?

A StyleSheet is a group of declarations, in a text file or in a report request, that describe how you want your report to look. These declarations:

You can create a StyleSheet using any text editor, including TED, the FOCUS text editor.

FOCUS uses the same default style for all report components if you do not create a StyleSheet.

With a StyleSheet, you only have to define the styles of those components to be displayed differently from the default style. Any component not specifically formatted in your StyleSheet either uses the default style or inherits a style from a higher-level component. Inheritance is discussed in FOCUS StyleSheet Attribute Inheritance.

When you create a styled report, your page layout differs from a standard FOCUS report. This variation is a function of the page layout parameters FOCUS uses for the two kinds of reports:


Top of page

x
What Is a Style?

Reference:

A style is a description of the physical characteristics of a report component; it consists of four basic attributes:

You can also define such attributes as background colors, grids, borders, and images in a StyleSheet declaration.



x
Reference: Reproducing StyleSheet Examples

The sample reports use the default page size specification for PDF and PS reports, LETTER, which represents 8.5 x 11 inch pages. They have been scaled down to accommodate the size of this manual.

If the fonts you have on your system do not include the ones used in the examples, substitute suitable and available fonts before you run the examples.


Top of page

x
Comparison of Reports With and Without StyleSheets

In a non-styled FOCUS report request, you can set values for the maximum number of lines on the output page (LINES), the number of lines on the printed page (PAPER), and the maximum number of characters in a report panel (PANEL). FOCUS then uses the typeface and size defined by your printer setup for all data in the report.

In a styled report, you can specify measurement units such as inches or points, and you can control column width or spacing. You can also change typefaces, type size, and type style for any part of the report.

In a PostScript or PDF report, you can also set margins on the top, bottom and sides of the report, and you can set the page size for letters, envelopes, and many other types of paper. The following table compares your options with and without StyleSheets:

 

With StyleSheets

Without StyleSheets

Text font

You can use different font sizes and fonts. You can selectively apply text styles such as bold or italic.

FOCUS uses the default font specified in your printer setup for the entire report.

Colors

You can select a color for the text or background.

The ink and paper in your printer determine the colors in your report.

Individual components

You can assign different styles to individual report components.

FOCUS uses a single style for the entire report.

Conditional styling

You can apply different styles to the same component based on report values.

Report format does not change with changes in report values.

Column widths

You can have column widths based on the column content, the field format specified in the Master File, or specify a width.

FOCUS bases column widths on the column title or the field format specified either in the Master File or the report request.

Column placement

You can specify the starting position of individual columns and arrange columns in any order regardless of the sequence established in the report request. In addition, you can indicate how much space to leave before and after individual columns.

You can specify the starting position of individual columns in the report request.

Page size

You can select from a wide range of page sizes for PostScript and PDF reports.

You can specify the number of lines per page within the limits of your printer setup.

Page orientation

You can select either portrait or landscape for PostScript, PDF, and EXL2K reports.

FOCUS uses the default orientation specified in your printer setup.

Page margins

You can specify the top, bottom, left, and right margins, measured in inches, centimeters, or points for PostScript and PDF reports.

FOCUS uses the default page margins specified in your printer setup.

Justification

You can justify individual report components.

You can justify column titles.


Top of page

x
Creating a StyleSheet

How to:

There are two ways to create a StyleSheet:

You can take advantage of most StyleSheet options without ever having to create a StyleSheet.

You can select a StyleSheet, page size, orientation, and margins at the FOCUS command level (if you want to apply them to your entire FOCUS session), or in a report request (if you want to apply them to one report).

You need to create a StyleSheet file if you wish to:



x
Syntax: How to Create a StyleSheet in a Report Request
ON TABLE SET STYLE *
.
.
.
ENDSTYLE

where:

STYLE *

Indicates the beginning of an inline StyleSheet.

ENDSTYLE

Indicates the end of an inline StyleSheet.

Note: You can omit the keyword ENDSTYLE, but only if it is immediately followed by the keyword END in the report request.



Example: Creating a StyleSheet Within a Report Request

In the following report request, the StyleSheet syntax appears in bold.

TABLE FILE EMPLOYEE
PRINT EMP_ID FIRST_NAME LAST_NAME
BY DEPARTMENT 
ON TABLE HOLD FORMAT PS
ON TABLE SET STYLE *
TYPE=REPORT, FONT=TIMES, SIZE=10, $
TYPE=REPORT, COLUMN=EMP_ID, RIGHTGAP=1, $
ENDSTYLE 
END

The request produces the following report, in which the font for the entire report and the amount of space to the right of the EMP_ID field have been changed:



x
Syntax: How to Activate an Existing StyleSheet File

The syntax for the SET command is:

SET STYLE[SHEET] = styoption

and the syntax in a report request is

TABLE FILE file 
request 
ON TABLE SET STYLE styoption 
END

where:

styoption

Is one of the following options:

ON uses default styles. This is the default setting. With this setting in effect, FOCUS uses the page layout settings for UNITS, TOPMARGIN, BOTTOMMARGIN, LEFTMARGIN, RIGHTMARGIN, PAGESIZE, ORIENTATION, and SQUEEZE, and ignores the settings for LINES, PAPER, PANEL, and WIDTH. Each display format has its own set of defaults. For example, HTML defaults to a proportional font, while PDF defaults to a monospace font.

OFF uses default styles. In this case, FOCUS uses the settings for LINES, PAPER, PANEL, and WIDTH, and ignores the settings for UNITS, BOTTOMMARGIN, LEFTMARGIN, RIGHTMARGIN, TOPMARGIN, PAGESIZE, ORIENTATION, and SQUEEZE. The report is printed in fixed-width Courier typeface with .250-inch margins. You can use this setting to print traditional-looking FOCUS reports on PostScript printers.

Note: To disable StyleSheets entirely so that no StyleSheet is activated, use the ONLINE-FMT setting discussed in Creating a Styled Report.

stysheet is the one- to eight-character name of a StyleSheet file. This setting activates the named StyleSheet. FOCUS uses the page layout settings for UNITS, TOPMARGIN, BOTTOMMARGIN, LEFTMARGIN, RIGHTMARGIN, PAGESIZE, ORIENTATION, and SQUEEZE, and ignores the settings for LINES, PAPER, PANEL, and WIDTH.


Top of page

x
StyleSheet Syntax

A StyleSheet consists of a series of declarations that describe how your report will look. Each declaration:

In your StyleSheet, include declarations for only those components whose format to change. Within each declaration, include only those formatting attributes to change.

Each declaration in a StyleSheet consists of attribute=value pairs separated by commas, and terminated with a comma and dollar sign (,$). The attributes that select a component or subcomponent must come first in each declaration. You can specify all other attributes in any order. The syntax is:

TYPE=value1, attribute2=value2, ... ,$

Note:

The attributes in the StyleSheet file identify report components, manipulate them, and define styles for formatting them.


Top of page

x
Improving FOCUS StyleSheet Readability

There are many ways to structure your StyleSheet declarations in order to make the StyleSheet easy to read. You can do any one, or a combination, of the following:


Top of page

x
Adding a Comment to a FOCUS StyleSheet

You can add comments to a StyleSheet to give context to a declaration. Comments do not affect StyleSheet behavior.

You can add a comment:

Note: You can add comments anywhere in your request, not only in StyleSheets.


Top of page

x
Checking StyleSheet Syntax

How to:

You can check the syntax of a StyleSheet from the FOCUS prompt with the CHECK STYLE command.



x
Syntax: How to Check StyleSheet Syntax
CHECK STYLE filename

where:

filename

Is the name of the StyleSheet file.

FOCUS reports any syntax errors in the StyleSheet file. It does not verify whether the specified fonts are available or whether the font names are spelled correctly.


Information Builders