Aligning Heading and Footing Elements

In this section:

To align text and data in headings and footings based on factors other than left, right, and center justification, consider the following descriptions before deciding which alignment method best suits your needs.

Alignment Method

Applies to ...

When to use...

Related Methods

1) StyleSheet Attributes:

HEADALIGN

COLSPAN

JUSTIFY

Details: See Aligning a Heading or Footing Element in an HTML, EXL2K, or PDF Report.

HTML

EXL2K

PDF

To align heading or footing items in HTML and EXL2K reports: If you expect to display reports in HTML or EXL2K format, use HEADALIGN options to align heading and footing items with either columns in the HTML table for the body of the report or with cells in an embedded HTML table. The browser handles alignment based on your specifications, without requiring unit measurements, which are required with WIDTH and JUSTIFY.

To align heading or footing items in PDF reports: If you expect to display reports in PDF format, use the HEADALIGN=BODY option to align heading and footing items with columns in the report body.

To specify a heading or footing item that spans multiple columns: You can combine HEADALIGN syntax with the COLSPAN attribute to achieve this result. For details, see Aligning a Heading or Footing Element Across Columns in an HTML or PDF Report.

 

2) StyleSheet Attributes:

WIDTH

JUSTIFY

Details: See Aligning Content in a Multi-Line Heading or Footing.

HTML

PDF

PS

For portability between HTML and PDF: To code a request that can be used without revision to produce identical output in HTML (with internal cascading style sheets) and in PDF, use WIDTH and JUSTIFY attributes in your StyleSheet. These settings can be applied to report, page, and sort headings and footings.

To align heading or footing items: Used together, WIDTH and JUSTIFY allow you to align specific items in the heading, rather than entire headings or footings or entire heading or footing lines, where the implied justification width is the total width of the report panel. To right- or center-justify an item in a heading or footing, you must know the width of the area you want to justify it in. That information is provided by the WIDTH attribute.

To align decimal points in a multi-line heading or footing: Use this technique to align decimal points in data that has varying numbers of decimal places. Define the width of the decimal item, then measure how far in from the right side of a column you want to position the decimal point. This places the decimal point in the same position in a column, regardless of the number of decimal places displayed to its right.

For an HTML, PDF, or EXL2K report, you can align specific items with HEADALIGN options.

3) StyleSheet Attribute:

POSITION

Details: See Positioning a Report Component.

PDF

PS

HTML (limited)

To set starting positions for headings or footings, or items within them: Use POSITION syntax to specify absolute and relative starting positions.

In HTML, with an internal cascading style sheet, you can use POSITION to specify the starting point for a heading or footing line. You can also position an image in a heading or footing.

To align heading and footing items with columns: Use POSITION syntax to align a heading item with a column position. For example, the syntax

TYPE=SUBHEAD, LINE=1,  
ITEM=3,POSITION=SALES, $

places ITEM 3 of the sort heading at the horizontal position where the column SALES is.

For a PDF report, you can accomplish most positioning with WIDTH and JUSTIFY.

For an HTML report, you can align a heading item with a column by setting the HEADALIGN attribute to BODY.


Top of page

x
Aligning a Heading or Footing Element in an HTML, EXL2K, or PDF Report

How to:

For HTML output (and for Excel 2000 output, which uses HTML alignment), you can position text and field items in headings and footings using HEADALIGN options. These options work within the limitations of HTML and browser technologies to provide a significant degree of formatting flexibility. Here is how HEADALIGN works.

For PDF output, you can use the HEADALIGN=BODY option to align heading and footing elements with the report body.

When HEADALIGN is set either to BODY or INTERNAL, output is laid out as an HTML table, which means that the browser determines the widths of the columns, thereby limiting the precise positioning of items. A basic rule governs the placement of heading or footing items: each item (text or embedded field) is placed in sequence into the next HTML table cell (<TD>). When HEADALIGN is set to NONE, the default, all the items in the heading or footing are strung together, inside a single cell. The browser stretches the heading table and the report table to accommodate the length of the text.

You can exercise control over the placement of items by overriding the default and choosing either BODY or INTERNAL:

To break a text string into multiple parts for manipulation across columns in an HTML table, you can use <+0> spot markers in the request.

You can use HEADALIGN options in conjunction with the COLSPAN attribute. COLSPAN allows heading items to span multiple table columns, thereby providing additional flexibility in how you can design your headings. For details, see Aligning a Heading or Footing Element in an HTML, EXL2K, or PDF Report.

If there is more than one heading or footing type in a report, you can individually align any element within each of them using this syntax.



x
Syntax: How to Align a Heading or Footing Element in an HTML Report
TYPE = {REPORT|headfoot}, HEADALIGN = option, $

where:

REPORT

Applies the chosen alignment to all heading and footing elements in a report.

headfoot

Is the type of heading or footing. Valid values are TABHEADING, TABFOOTING, HEADING, FOOTING, SUBHEAD, and SUBFOOT.

option

Is the type of alignment. Valid values are:

NONE which places heading items in an embedded HTML table inside the main (body) table, and strings together, in a single cell of the embedded table, all the heading items (text and fields) on a line. In PDF reports, this uses the default alignment heading alignment. This value is the default.

INTERNAL which places heading items in an HTML table of its own, with each item in a separate cell. This allows the heading items to be aligned vertically with each other, independent of the data columns. The widths of the heading items do not affect the widths of the report columns and vice versa. Note: HEADALIGN=INTERNAL is not supported in PDF reports.

BODY which aligns heading items with data columns by placing the items in the cells of the same HTML table as the body of the report. Since they have the same column widths, the items in the heading and the data in the body of the report line up naturally. For PDF output, this aligns the heading or footing elements with the data columns. Note: HEADALIGN=BODY does not support paneling.



Example: Aligning Elements in a Page Heading Using a Separate HTML Table

This request creates an embedded HTML table for a page heading, within the HTML table that governs alignment in the body of the report. This table has three rows and three columns to accommodate all the heading elements.

In the first line of the heading, a spot marker (<+0>) creates two text elements: the first element is blank, and the second element is Gotham Grinds, Inc. In the output, the second element appears in the second cell of the first row of the embedded table.

The second and fourth lines of the heading are blank.

The spot markers in the third line of the heading split it into three text elements: Orders Report, blank, Run on: &DATE. In the output, each element appears in a cell in the third row of the embedded HTML table, in the order specified in the request.

TABLE FILE GGORDER
HEADING 
" <+0>Gotham Grinds, Inc."
" "
"Orders Report <+0> <+0> Run on: &DATE"
" " 
PRINT ORDER_NUMBER ORDER_DATE STORE_CODE QUANTITY
BY PRODUCT_CODE BY PRODUCT_DESCRIPTION
IF RECORDLIMIT EQ 10
ON TABLE SET PAGE-NUM OFF
ON TABLE HOLD FORMAT HTML
ON TABLE SET STYLESHEET * 
TYPE = REPORT, GRID = ON, $
TYPE = HEADING, HEADALIGN = INTERNAL, STYLE = BOLD, $ 
ENDSTYLE
END

GRID=ON in the request enables you to see the embedded HTML table for the heading, and the main HTML table for the body of the report. The positioning is maintained when the grid lines are hidden (off).

The output is:



Example: Aligning Subfooting Items With Report Columns in PDF Report Output

In the following request against the GGORDER data source, the subfooting has a text object ("Total") and a field object (ST.QUANTITY). The subfooting aligns the items with their report columns using TYPE=SUBFOOT, HEADALIGN=BODY ,$. The text object is placed in the second report column using the <+0 spot marker, and the field object is placed in the third report column using another <+0 spot marker. Then the text item is left aligned (the default) with its report column. The field object is right aligned with its report column:

TABLE FILE GGORDER
PRINT QUANTITY
ORDER_NUMBER ORDER_DATE STORE_CODE 
BY PRODUCT_CODE BY PRODUCT_DESCRIPTION
WHERE ORDER_DATE EQ '01/01/96'
WHERE STORE_CODE EQ 'R1019' 
ON PRODUCT_CODE SUBFOOT
" <+0 Total: <+0 <ST.QUANTITY" 
ON TABLE SET PAGE-NUM OFF
ON TABLE PCHOLD FORMAT PDF
ON TABLE SET STYLESHEET *
TYPE = SUBFOOT,HEADALIGN=BODY, $
TYPE = SUBFOOT,OBJECT=TEXT,STYLE = BOLD, $
TYPE = SUBFOOT,OBJECT=FIELD,JUSTIFY=RIGHT,STYLE = BOLD, $
ENDSTYLE
END

The output shows that the text Total is aligned with the product names and the subtotal field object is right aligned with the Ordered Units column.



Example: Using OVER With HEADALIGN=BODY in a PDF Report

When aligning heading elements with the data line using HEADALIGN=BODY, the first row of fields serves as the anchor data row. Each heading line contains the number of columns presented in the anchor data row. Any additional columns that may appear on other data lines are not presented. If the first row of data contains fewer data value cells than other data rows, you will be unable to add alignment columns within headings for these additional columns.

In the following example, the first row (the anchor data row) contains a single value. Items placed in headings to correspond with column two that appears on subsequent rows are not displayed

SET LAYOUTGRID=ON
TABLE FILE GGSALES
"Product<+0>"
"Units<+0>Dollars"
SUM
PRODUCT AS ''
OVER
UNITS/D8C AS '' DOLLARS/D12.2CM AS ''
BY PRODUCT NOPRINT
ON TABLE PCHOLD FORMAT PDF
ON TABLE SET STYLE *
TYPE=REPORT, SQUEEZE=ON,FONT=ARIAL, SIZE=8, LEFTGAP=.1, RIGHTGAP=.1, GAPINTERNAL=ON, $
TYPE=REPORT, BORDER=ON, $
TYPE=HEADING, BORDERALL=ON, HEADALIGN=BODY, $
TYPE=HEADING, LINE=1, ITEM=1, COLSPAN=2, WIDTH=2, JUSTIFY=LEFT, $
TYPE=HEADING, LINE=2, ITEM=1, WIDTH=1, JUSTIFY=LEFT, $
TYPE=HEADING, LINE=2, ITEM=2, WIDTH=1, JUSTIFY=LEFT, $
TYPE=REPORT, COLUMN=PRODUCT(2),   SQUEEZE=2,  $
TYPE=REPORT, COLUMN=UNITS, SQUEEZE=1, $
TYPE=REPORT, COLUMN=DOLLARS, SQUEEZE=1, $
END

The output shows that the heading lines have one column each, while the data lines alternate between one column and two columns:


Top of page

x
Aligning a Heading or Footing Element Across Columns in an HTML or PDF Report

How to:

With HEADALIGN=BODY, each heading or footing element is aligned with a data column in an HTML or PDF report; with HEADALIGN=INTERNAL, each element is continued in a column of an HTML table created and aligned specifically for the report heading or footing. By default, every heading or footing element (ITEM) is placed in the first available column. However, you can position an item to span multiple columns using the COLSPAN attribute. For details about HEADALIGN options, see Aligning a Heading or Footing Element in an HTML, EXL2K, or PDF Report.

You must specify the HEADALIGN and COLSPAN attributes in two separate StyleSheet declarations, since HEADALIGN applies to an entire heading or footing, while COLSPAN applies to a specific item in a heading or footing. This feature is supported for HTML only. PDF display format does not support the COLSPAN attribute.



x
Syntax: How to Align a Heading or Footing Element Across Columns
TYPE = headfoot, [subtype,] COLSPAN = n, $

where:

headfoot

Is the type of heading or footing. Valid values are TABHEADING, TABFOOTING, HEADING, FOOTING, SUBHEAD, and SUBFOOT.

subtype

Are additional attributes that identify the report component. These options can be used separately or in combination, depending upon the degree of specificity required to identify an element. Valid values are:

LINE which identifies a line by its position in a heading or footing. Identifying individual lines enables you to format each line differently.

If a heading or footing has multiple lines and you apply a StyleSheet declaration that does not specify LINE, the declaration is applied to all lines. Blank lines are counted when interpreting the value of LINE.

OBJECT which identifies an element in a heading or footing as a text string or field value. Valid values are TEXT or FIELD. TEXT may represent free text or a Dialogue Manager amper (&) variable.

It is not necessary to specify OBJECT=TEXT unless you are styling both text strings and embedded fields in the same heading or footing.

ITEM which identifies an item by its position in a line. To divide a heading or footing line into items, you can use the <+0> spot marker.

To determine the ITEM for an OBJECT, follow these guidelines:

  • When used with OBJECT=TEXT, count only the text strings from left to right.
  • When used with OBJECT=FIELD, count only values from left to right.
  • When used without OBJECT, count text strings and field values from left to right.

    If you apply a StyleSheet declaration that specifies ITEM, the number is counted from the beginning of each line in the heading or footing, not just from the beginning of the first line.

COLSPAN

Is an attribute that aligns an item in the width spanned by multiple columns.

n

Is the column with which the specified item is aligned.



Example: Comparing Output Generated With HEADALIGN Options

The requests that follow illustrate the differences in alignment with each HEADALIGN setting. The grid lines are exposed in the output to help distinguish the HTML table created for the body of the report from the embedded HTML tables created for the heading in some variations.

All HEADALIGN settings are compatible with COLSPAN syntax, which allows heading items to span multiple columns.

TABLE FILE CAR
SUM SALES BY COUNTRY BY CAR BY MODEL
ON COUNTRY SUBHEAD
"This is my subhead"
" "
"Country is:<COUNTRY Car is:<CAR"
"Model is:<MODEL"
IF COUNTRY EQ 'ENGLAND'
ON TABLE SET PAGE-NUM OFF
ON TABLE HOLD FORMAT HTML
ON TABLE SET STYLESHEET * 
TYPE=SUBHEAD, HEADALIGN=OPTION, $ 
TYPE=SUBHEAD, LINE=1, ITEM=1, COLSPAN=4, JUSTIFY=CENTER, $ 
ENDSTYLE
END

HEADALIGN=NONE creates a separate table with default left alignment. The text and fields in each heading line are strung together in a single HTML table cell. In order to get this result, do not include the TYPE=SUBHEAD line that contains the COLSPAN=R, JUSTIFY=CENTER attributes in the StyleSheet:

TYPE=SUBHEAD, HEADALIGN=NONE, $

HEADALIGN=NONE with COLSPAN

TYPE=SUBHEAD, HEADALIGN=NONE, $
TYPE=SUBHEAD, LINE=1, ITEM=1, COLSPAN=4, JUSTIFY=CENTER, $

The first line is centered across all four columns of the internal table, based on the COLSPAN=4 setting.

HEADALIGN=INTERNAL creates a separate HTML table. Columns are generated based on the number of items (text and fields) in the heading; each item is placed in a separate cell. These columns do not correspond to those in the HTML table for the report body.

TYPE=SUBHEAD, HEADALIGN=INTERNAL, $

Country is aligned with Model in the first column of the internal table. The value of <COUNTRY is aligned with the value of <MODEL in the second column.

HEADALIGN=INTERNAL with COLSPAN

TYPE=SUBHEAD, HEADALIGN=INTERNAL, $
TYPE=SUBHEAD, LINE=1, ITEM=1, COLSPAN=4, JUSTIFY=CENTER, $

The first line is centered across all 4 columns of the internal table, based on the COLSPAN=4 setting.

HEADALIGN=BODY places the heading lines within the cells of the main HTML table. As a result, the columns of the heading correspond to the columns of the main table.

TYPE=SUBHEAD, HEADALIGN=BODY, $

Country is aligned with Model in the first column of the main (body) HTML table. The value of <COUNTRY is aligned with the value of <MODEL in the second column.

HEADALIGN=BODY with COLSPAN

TYPE=SUBHEAD, HEADALIGN=BODY, $
TYPE=SUBHEAD, LINE=1, ITEM=1, COLSPAN=4, JUSTIFY=CENTER, $

COLSPAN controls the cross-column alignment of the first row of the heading.



Example: Aligning and Styling a Text Field in a Sort Footing

This example uses the following Master File and MODIFY procedure to create a data source with a text field:

Master File:

FILENAME = TXTFLD, SUFFIX = FOC,$
SEGNAME=TXTSEG, SEGTYPE = S1,$
   FIELDNAME = CATALOG, FORMAT = A10, $
   FIELDNAME = TEXTFLD,     FORMAT = TX50,$

MODIFY Procedure to create the TXTFLD data source:

CREATE FILE TXTFLD
MODIFY FILE TXTFLD
FIXFORM CATALOG/10 TEXTFLD
DATA
COURSE100 This course provides the junior programmer
with the skills needed to code simple reports.%$
COURSE200 This course provides the advanced programmer with
techniques helpful in developing complex
applications.%$
END

This request applies boldface type to the second line of a multiple-line sort footing, which includes the text Course Description as well as the text of the field TEXTFLD. Line 1 of the sort footing is the text Evening Course.

TABLE FILE TXTFLD
BY CATALOGA SUBFOOT 
"Evening Course"
"Course Description: <TEXTFLD" 
ON TABLE SET PAGE-NUM OFF
ON TABLE HOLD FORMAT HTML
ON TABLE SET STYLESHEET *
TYPE = REPORT, GRID = OFF, $ 
TYPE = SUBFOOT, HEADALIGN = BODY, $
TYPE = SUBFOOT, LINE = 2, STYLE = BOLD, $ 
ENDSTYLE
END

The output is:

If the StyleSheet instead identifies the text field as an object for styling

TYPE = SUBFOOT, HEADALIGN = BODY, $
TYPE = SUBFOOT, LINE = 2, OBJECT = FIELD, STYLE = BOLD, $

then only the text in TEXTFLD is bold:



Example: Aligning a Field Value Across Multiple Columns in a PDF Report

In this request, HEADALIGN=BODY aligns the sort footing in the same grid as the body of the report. COLSPAN=5 positions the first item in the sort footing (the text Total) in the fifth column of the report output. The second item in the sort footing (the field <ST.QUANTITY) is positioned in the next available column. The subfooting items are right justified.

The HEADALIGN attribute is on a separate line from the COLSPAN attribute because it applies to the entire sort footing (and consequently to both items), whereas COLSPAN applies only to the text item Total.

TABLE FILE GGORDER
PRINT ORDER_NUMBER ORDER_DATE STORE_CODE QUANTITY
BY PRODUCT_CODE BY PRODUCT_DESCRIPTION
WHERE ORDER_DATE EQ '01/01/96'
WHERE STORE_CODE EQ 'R1019'
ON PRODUCT_CODE SUBFOOT
"Total:<ST.QUANTITY"
""
ON TABLE SET PAGE-NUM OFF
ON TABLE PCHOLD FORMAT PDF
ON TABLE SET STYLESHEET *
TYPE=REPORT, FONT=ARIAL, SQUEEZE=ON,$ 
TYPE = SUBFOOT, HEADALIGN = BODY, JUSTIFY = RIGHT, STYLE = BOLD, $
TYPE = SUBFOOT, ITEM=1, COLSPAN = 5, $
ENDSTYLE
END

The output shows that the first item in the sort footing (the text Total) is in the fifth column of the report output. The second item in the sort footing (the field <ST.QUANTITY) is positioned in the next available column.


Top of page

x
Aligning Content in a Multi-Line Heading or Footing

How to:

Reference:

The HEADALIGN and COLSPAN syntax described in Aligning a Heading or Footing Element in an HTML, EXL2K, or PDF Report is specific to HTML reports. This topic describes how you can design reports that are printable across HTML and PDF formats. Using the WIDTH and JUSTIFY syntax in a StyleSheet, you can:

You can apply WIDTH and JUSTIFY attributes to report headings and footings, page headings and footings, and sort headings and footings, using either mono-space or proportional fonts.

These techniques rely on internal cascading style sheets, which support FOCUS StyleSheet attributes that were not previously available for HTML reports. The syntax associated with these techniques resolves the problem of having to format headings differently for HTML reports (using HEADALIGN and COLSPAN) and PDF and PS reports (using POSITION and spot markers).

While the WIDTH and JUSTIFY attributes are particularly useful when you need to format a multi-line heading or footing, or align stacked decimals, you can also use this syntax to position items in an individual heading or footing line.



x
Syntax: How to Align Heading Text and Data in Columns

For a multi-line report or page heading or footing, use the syntax:

TYPE=headfoot, WRAP=OFF, $
TYPE=headfoot, [LINE=line_#,] ITEM=item_#, [OBJECT={TEXT|FIELD}],
 WIDTH=width,   [JUSTIFY=option,] $

For a multi-line sort heading or footing, use the syntax

TYPE=headfoot, WRAP=OFF, $
TYPE={SUBHEAD|SUBFOOT}, [BY=sortfield] [LINE=line_#,] ITEM=item_#,
 [OBJECT={TEXT|FIELD}], WIDTH=width, [JUSTIFY=option,] $

where:

headfoot

Is the type of heading or footing. Valid values are TABHEADING, TABFOOTING, HEADING, FOOTING, SUBHEAD, and SUBFOOT.

sortfield

When TYPE=SUBHEAD or SUBFOOT, you can specify alignment for the sort heading or sort footing associated with a particular sort field. If no sort field is specified, formatting is applied to the sort headings or footings associated with all sort fields.

LINE

Is an optional entry that identifies a line by its position in a heading or footing. Identifying individual lines enables you to format each one differently.

If a heading or footing has multiple lines and you apply a StyleSheet declaration that does not specify LINE, the declaration is applied to all lines. Blank lines are counted when interpreting the value of LINE.

You can use LINE in combination with ITEM.

ITEM

Is a required entry when you are using WIDTH to control alignment. An item can identify either:

  • A vertical set of text or data that you wish to align as a columnar unit. You must identify each vertical unit as an item.
  • An item's position in a line. You must identify each line element as an item. See Line and Item Formatting in a Multi-Line Heading or Footing for information about acceptable variations.

You can use either or both approaches for a single heading or footing.

To divide a heading or footing line into items, you can use the <+0> spot marker. The number of items you can identify is limited by the cumulative widths of the items in the heading or footing, within the physical boundaries of the report page.

You can use ITEM in conjunction with OBJECT to refine the identification of an element whose width you want to define. To determine the ITEM for an OBJECT, follow these guidelines:

  • When used with OBJECT=TEXT, count only the text strings from left to right.
  • When used with OBJECT=FIELD, count only values from left to right.
  • When used without OBJECT, count text strings and field values from left to right.

If you apply a StyleSheet declaration that specifies ITEM, the number is counted from the beginning of each line in the heading or footing, not just from the beginning of the first line

OBJECT

Is an optional entry that identifies an element in a heading or footing as a text string or field value. Valid values are TEXT or FIELD. TEXT may represent free text or a Dialogue Manager amper (&) variable.

It is not necessary to specify OBJECT=TEXT unless you are styling both text strings and embedded fields in the same heading or footing.

width

Is the measurement expressed in units (inches by default), which is required to accommodate the longest text string or field value associated with a numbered item. For details, see How to Measure for Column Width and Decimal Alignment.

option

Is the type of justification. Valid values are:

LEFT which left justifies the heading or footing. This value is the default.

RIGHT which right justifies the heading or footing.

CENTER which centers the heading or footing.

DECIMAL (n)

Is the measurement expressed in units (inches by default), which specifies how far in from the right side of a column to place the decimal point. With this specification, you can locate the decimal point in the same position within a column, regardless of the number of decimal places displayed to its right.

The measurement will be a portion of the width specified for this item. For details, see How to Measure for Column Width and Decimal Alignment.



x
Reference: Line and Item Formatting in a Multi-Line Heading or Footing

Line formatting maximizes your control over the items you identify on each line:

Do not use HEADALIGN or COLSPAN syntax, which are specific to HTML reports and may conflict with WIDTH and JUSTIFY settings.

For HTML reports, turn WRAP OFF (ON is the default) to ensure proper processing of WIDTH and JUSTIFY.



Example: Aligning Data and Text in a Multi-Line Heading or Footing

In the following free-form report, content is defined entirely in the sort heading, where text and data are stacked to support comparison among manufacturing plants. Each set of data is aligned vertically, to appear as a column. To achieve this affect, each vertical unit is identified as an item: the first column of text is item 1; the next column of data is item 2, and so on.

Note especially the last column, in which decimal data with different numbers of decimal places is lined up on the decimal point to facilitate reading and comparison.

The chart below breaks out the structure of the previous report:

Item1:

Text

Item 2:

Data values

Item 3:

Text

Item 4:

Values with decimal places

Plant

BOSDAL, and so on

Quantity

n,nnn,nnn

Order Date

2002/01/02

Cost of Goods

nnn,nnn,nnn.ddddd

Store Code

1003MD

Line Total

$nnn,nnn,nnn.dd

For each item, you specify the width of the column and the justification of its content, as illustrated in the following code.

DEFINE FILE CENTORD
COST/D20.5 = LINE_COGS * .75 ;
END
 
TABLE FILE CENTORD
BY PLANT NOPRINT SUBHEAD 
"Plant: <PLANT Quantity: <QUANTITY"
"Order Date: <ORDER_DATE Cost of Goods: <COST"
"Store Code: <STORE_CODE Line Total: <LINEPRICE" 
ON TABLE SET PAGE-NUM OFF 
ON TABLE SET HTMLCSS ON 
ON TABLE HOLD FORMAT HTML
ON TABLE SET STYLESHEET *
TYPE=REPORT, FONT='TIMES', $
TYPE=REPORT, GRID=OFF, $ 
TYPE=SUBHEAD, ITEM=1, WIDTH=1.00, JUSTIFY=RIGHT, $
TYPE=SUBHEAD, ITEM=2, WIDTH=1.25, JUSTIFY=RIGHT, $
TYPE=SUBHEAD, ITEM=3, WIDTH=1.25, JUSTIFY=RIGHT,$
TYPE=SUBHEAD, ITEM=4, WIDTH=2.0,  JUSTIFY=DECIMAL(.6),$  
ENDSTYLE
END

This procedure produces a three-line sort heading, broken out as four items, each with a measured width and defined justification. The decimal item (4) uses a variation on standard justification to line up the decimal points. For details, see How to Align Heading Text and Data in Columns and Aligning Decimals in a Multi-Line Heading or Footing.

Note: To take advantage of this feature for an HTML report, turn on internal cascading style sheets (SET HTMLCSS=ON). This command enables FOCUS StyleSheet attributes that were not previously available for HTML reports. This line of code is ignored for a PDF report.


Top of page

x
Aligning Decimals in a Multi-Line Heading or Footing

How to:

The ability to align heading content in a multi-line heading based on width and justification values has special benefit in reports that contain data with different numbers of decimal places. For example, if a figure is in dollars, it is formatted with a decimal point and two places for zeroes; if in Swiss francs, it is formatted with a decimal place and four zeroes; if in yen, the decimal is at the end with no zeroes. In addition, sometimes the currency or units do not vary, but the number of digits of decimal precision varies.

By aligning the decimal points in a vertical stack, you can more easily read and compare these numbers, as illustrated in the following output:

Floating decimal points

Aligned decimal points

Bond
------------
Galosh Ltd.
Mukluk Inc.
Overshoe Inc.
 Face Value
------------
22375.5784596
 1212345.457
232.45484
Bond
------------
Galosh Ltd.
Mukluk Inc.
Overshoe Inc.
    Face Value
  -------------
  22375.5784596
1212345.457
    232.45484

The technique uses a width specification for the item that contains decimals, combined with a variation on standard left/right/center justification to achieve the proper decimal alignment. For the syntax that generates this output, see How to Align Heading Text and Data in Columns.



x
Procedure: How to Measure for Column Width and Decimal Alignment

Measuring Width. Determining the width of a heading or footing item is a three-step process:

  1. Identify the maximum number of characters in a text string or field.
  2. For a text string, simply count the characters. For a field, refer to the format specification in the Master File or in a command such as a DEFINE.
  3. Measure the physical space in units (for example, in inches) that is required to display the number of characters identified in step 1, based on the size of the font you are using. For example, the following value of the COUNTRY field would measure as follows:

    Font

    Font size

    Comparison

    Inches

    Helvetica

    10

    England

    .5

    Times New Roman

    10

    England

    .44

    Courier

    10

    England

    .56

    Tip: Consider using a consistent set of fonts in your reports to make your measurements reusable.

Measuring for Decimal Alignment. After you have determined the width of an item, you can do a related measurement to determine the physical space required to display decimal data with a varying number of digits to the right of the decimal point.

  1. Determine the maximum number of decimal places you need to accommodate to the right of the decimal place, plus the decimal point itself.
  2. Measure the physical space in units (for example, in inches) that is required to display the number of characters identified in step 1, based on the size of the font you are using.

Top of page

x
Combining Column and Line Formatting in Headings and Footings

By combining column and line formatting, you can create complex reports in which different ranges of lines in the same heading or footing have different numbers of aligned columns in different locations.



Example: Combining Column and Line Formatting to Align Items in a Sort Heading

This request produces a free-form report in which content is defined in a seven-line sort heading. Data is stacked in two groupings:

Although this is a single sort heading, our goal is to format the information in each grouping a bit differently to provide emphasis and facilitate comparison. The request also demonstrates a coding technique that makes formatting changes easier for the report designer. See the annotations following the code for details.

As you review the sample request, keep in mind that a heading can contain two kinds of items: text and embedded fields. A text item consists of any characters, even a single blank, between embedded fields and/or spot markers. In particular, if you have a single run of text that you want to treat as two items, you can separate the two items using a <+0> spot marker. For example, in the heading line:

" <+0>Region:<REGION"

item #1 is a single blank space.

item #2, separated by the <+0> spot marker, is the text Region:

item #3 is the embedded field <REGION.

Request and annotations:

    TABLE FILE CENTORD
    BY REGION  NOPRINT SUBHEAD 
1.  " <+0>Region:<REGION" 
2.  " <+0>State :<STATE"
    " " 
3.  "Product Number:<PROD_NUM <+0>Quantity:<QUANTITY" 
4.  "Product Type:<PRODCAT <+0>Price:<PRICE" 
5.  "Product Category:<PRODTYPE <+0>Cost:<COST"
    " "
    ON TABLE SET PAGE-NUM OFF 
6.  ON TABLE SET HTMLCSS ON
    ON TABLE HOLD FORMAT HTML AS NF958055
    ON TABLE SET STYLESHEET *
    TYPE=REPORT, FONT='TIMES', $
    TYPE=REPORT, GRID=OFF, $
    -* Bottom section of subhead: 
7.  TYPE=SUBHEAD, ITEM=1, WIDTH=1.25, JUSTIFY=RIGHT, $ 
8.  TYPE=SUBHEAD, ITEM=2, WIDTH=1.00, JUSTIFY=RIGHT, $ 
9.  TYPE=SUBHEAD, ITEM=3, WIDTH=1.0, $ 
10. TYPE=SUBHEAD, ITEM=4, WIDTH=1.00, JUSTIFY=RIGHT,$ 
11. TYPE=SUBHEAD, ITEM=5, WIDTH=1.5, JUSTIFY=DECIMAL(.6),$
    -* Top section of subhead (overrides above ITEM defaults
    -*   for lines 1 and 2): 
12. -SET &INDENT = 1.5; 
13. TYPE=SUBHEAD, LINE=1, ITEM=1, WIDTH=&INDENT, $ 
14. TYPE=SUBHEAD, LINE=1, ITEM=2, WIDTH=1, JUSTIFY=LEFT, $ 
15. TYPE=SUBHEAD, LINE=1, ITEM=3, SIZE=14, WIDTH=2, JUSTIFY=LEFT, $ 
16. TYPE=SUBHEAD, LINE=2, ITEM=1, WIDTH=&INDENT, $ 
17. TYPE=SUBHEAD, LINE=2, ITEM=2, WIDTH=1, JUSTIFY=LEFT, $ 
18. TYPE=SUBHEAD, LINE=2, ITEM=3, WIDTH=1.25, JUSTIFY=LEFT, $
    ENDSTYLE
    END

Here is the output generated by this request. It highlights the key information and its relationship by aligning text and data, including decimal data in which decimal points are aligned for easy comparison.

Line #

Description

1-2

Defines the content for the top, two-line section of the sort heading. Each line contains three items: the first is a blank area (denoted by a space, separated from the next item by a <+0> spot marker); the second contains text; the third contains data values related to the text.

3-5

Defines the content for the bottom, three-line section of the sort heading. Each line contains five items: text; data values related to the text; a blank column (denoted by a space, separated from the next item by a null spot marker); text; data values related to the text.

6

Turns on internal cascading style sheets, a requirement for these formatting options. This command enables FOCUS StyleSheet attributes that were not previously available for HTML reports. This line of code is ignored for a PDF report.

7-11

Specifies the basic formatting characteristics for the sort heading by breaking the content into five columns, each identified as an item with a defined width, and justification information for all but the empty column.

Important: Had additional formatting code (annotated as 12-17) not been included in the request, the specifications annotated as 7-11 would have applied to the entire sort heading. That is, the formatting of the three columns in the top section of the heading would have been based on the specifications for the first three columns described below. However, that is not the desired effect, so a second section of StyleSheet code is defined to override this formatting for lines 1 and 2 of the sort heading. See annotations 12-18.

The formatting of the bottom, three-line section of the heading is controlled by the following specifications:

Item 1 identifies a columnar unit that contains text (that is, Product Number, Product Type, Product Category; it has a defined width of 1.25 inches and the text is right justified.

Item 2 identifies a columnar unit that contains data values related to the text in item 1; it has a defined width of 1 inch and the data is right justified.

Item 3 identifies a columnar unit that contains blank space and serves as a separator between columns; it has a width of 1 inch. Justification is not relevant.

Item 4 identifies a columnar unit that contains text (Quantity, Price, Cost); it has a defined width of 1 inch and the text is right justified.

Item 5 identifies a columnar unit that contains a decimal value; the width of the column that contains the value is 1.5 inches, with the decimal point anchored .6 inches in from the right edge of that column.

The common width and justification definitions enforce the proper alignment of each item.

12

Defines a variable called &INDENT, with a width setting of 1.5 inches. This variable defines the width of the blank area (item 1) at the beginning of lines 1 and 2 of the sort heading.

Defining the width as a variable enables you to experiment with different widths simply by changing the value in one location. For a complex report, this technique can potentially save development time.

13-18

Specifies line-by-line formatting for the top, two-line section of the sort heading. This code overrides the previous formatting for lines 1 and 2 of the sort heading because it specifies a line number.

Item 1 on each line refers to the blank area. The width is defined as a variable and implemented based on the current value of &INDENT.

Item 2 on each line refers to the text area; it has a defined width of 1 inch and the text is left justified.

Item 3 on each line refers to the data values; it has a defined width of 2 inches and the data is left justified.

The common width and justification definitions enforce the proper alignment of each item.

Notice that item 1 in line 15 defines a font size for the data values associated with the REGION field. All other items on both lines use a default font. Line-by-line formatting enables you to define a unique characteristic for a single item.


Information Builders