To edit a template, select it in the list of templates in the Template Editor. You can change the name of the template or its comments in the controls at the right. To edit the layout of the template, click the Edit button in the toolbar. This brings up the Advanced Report Designer, which you can use to change the layout of the template.
Use the Advanced Report Designer to edit a template the same way you use it to modify a normal report. You can add rectangles, lines, pictures (such as a company logo), and so forth. The objects in the template appear on every report using that template. You can also specify the paper size and source tray or bin. However, due to its nature, there are a few differences between a template and a normal report:
Some objects in a template are placeholders, which indicate where a particular object in a normal report is placed and how it's formatted. For example, in the picture above, the FIELDTEMPLATE object is a placeholder specifying how fields in the Detail band of the report appear and GROUPTEMPLATE is a placeholder for grouped fields.
Some objects need to be moved or resized as the report width adjusts based on the number of fields that appear in the report. For example, the Page Header object stretches horizontally so it's as wide as the report and the Page # object is moved to the right so it's at the right edge of the report.
You control both of these issues on the Other page of the Properties dialog for an object. For a field object, you can specify whether it's a template, or placeholder, object and how its size and position are adjusted.
The choices for the Template type setting are:
Not a template: this object is not a placeholder, but appears in every report using this template.
Detail field template: this object is a placeholder for fields that appear in the Detail band (all but grouped fields in quick reports and data area fields in cross-tab reports). The Expression for this object is unimportant ("FIELDTEMPLATE" is used in the templates that come with Reporting4Act! just to make it obvious what type of object this is), as is the size (the field is sized according to the data in the report), but other properties such as the font name, font size, foreground and background color, Print When settings, and so forth are used by field objects for a report. In addition, the vertical position of the placeholder is used to determine where in the Detail band fields go, and its horizontal position is used to determine the location of the first, leftmost, field.
Column heading template: this object is a placeholder for the column headings for fields, and should be placed in either the Page Header or Group Header bands. As with detail field template objects, the Expression and size are unimportant ("Column Heading" is used in the Expression in the templates that come with Reporting4Act!), but other properties, including the vertical and horizontal positions, are used.
Group field template: this object is a placeholder for grouped fields, and should go in the Group Header band. As with other template objects, the Expression and size are unimportant ("GROUPTEMPLATE" is used in the templates that come with Reporting4Act!), but other properties, including the vertical and horizontal positions, are used.
Group heading template: this object is a placeholder for the heading for grouped fields, and should go in the Group Header band, usually to the left of the group field template object. As with other template objects, the Expression and size are unimportant ("Group Heading" is used in the templates that come with Reporting4Act!), but other properties, including the vertical and horizontal positions, are used.
Group footer template: this object is a placeholder for grouped fields in the Group Footer band. Unlike some other template objects, the Expression is important. A value of "GROUPFOOTERTEMPLATE" means use the default group footer expression ("Totals for group value"); any other value is used as is. For example, use "Totals" to just display that. To include the group value in the expression, use {0} as a placeholder; for example, using "Totals for {0}:" gives the same results as "GROUPFOOTERTEMPLATE."
Other properties, including the vertical and horizontal positions, are also used. Unlike other template objects, however, how the width of group footer template objects is adjusted depends on the values of the Trim mode for character expression and Stretch with overflow settings. If Trim mode for character expression is set to Default trimming and Stretch with overflow is turned off, the object is sized according to its contents. If these are set to any other values, the object is sized so it does not bump into the left-most summary field.
For example, in the template used by the following report, Trim mode for character expression for the GROUPFOOTERTEMPLATE object is set to Filespec: Show inner path as ellipsis and Stretch with overflow is turned off. In this case, this object is only as wide as the amount of space available to the left of the subtotal field, and as a result, part of the value is replaced with "...".
Contrast this with the template used by the following report. Here, Trim mode for character expression is set to Default trimming and Stretch with overflow is turned off. In this case, this object is sized as wide as necessary for its contents, and as a result, there isn't room for the subtotal field on the same line, so it's moved to the next line.
Finally, with Stretch with overflow turned on, the object is only as wide as the amount of space available to the left of the subtotal field but the object stretches so it takes up as many lines as necessary, regardless of the setting of Trim mode for character expression.
Thus, you have control over whether grouped fields in the Group Footer band are sized to their contents, which may cause subtotals to move to the next line, or sized to allow subtotals on the same line.
Group summary template: this object is a placeholder for the subtotals or other calculations of fields in the Group Header band. As with other template objects, the Expression and size are unimportant ("GROUPSUMMARYTEMPLATE" is used in the templates that come with Reporting4Act!), but other properties, including the vertical and horizontal positions, are used.
Summary field template: this object is a placeholder for the grand totals or other calculations of fields in the Summary band. As with other template objects, the Expression and size are unimportant ("SUMMARYTEMPLATE" is used in the templates that come with Reporting4Act!), but other properties, including the vertical and horizontal positions, are used.
Summary total template: this object is only used as the text for the "totals" object at the end of cross-tab reports.
Subreport description template: this object is only used in subreports and shows the description of the subreport (see discussion of subreports below).
Page field heading template: this object is only used if a report has a page field and is used for the page field heading.
Page field template: this object is only used if a report has a page field and is used for the page field.
Even objects that aren't placeholders can have their size and/or position adjusted as necessary. The choices for the Size/position adjustments setting are:
No adjustments: the size and position of this object are not adjusted.
Stretch to page width: this object is stretched horizontally so its right edge aligns with the right edge of the page. This is typically used for lines or fields such as the Page Header object which should be the whole width of the page.
Align at page right edge: this object is moved horizontally so its right edge aligns with the right edge of the page. This is typically used for fields such as the Page # object which should print at the right edge of the page.
Match size/position to each field: this object is sized and positioned to match each field in the detail band. This is used for things such as a line above totals in a group footer.
Center: this object is centered horizontally on the page. This is useful for images.
Group headers and footers
If you want different group header and footer bands to be formatted differently, create as many data groups for the template as necessary. For example, suppose you want objects in the first group header to be formatted differently than any other group header. In that case, create two data groups using the Data Grouping page of the Report Properties dialog. The expression to use for the group isn't important; you can enter something like GROUPTEMPLATE1 for the first group and GROUPTEMPLATE2 for the second to keep them separate, but that isn't required. Then add the desired objects to each group header band and format them as desired. When you run a report using this template, objects in first group header are formatted as specified in the first group header of the template and objects in all other group headers are formatted the same as the template objects in the second group header of the template. If a report has more grouping than the template does, the last group in the template is used for that grouping level and all higher ones. See the Elegant template as an example of how to use this technique.
Subreports
If you want to use the template for reports containing subreports, add a second detail band by choosing Optional Bands from the Report menu and clicking the Add button in the Detail Bands section. Click OK to close the dialog, then right-click the grey bar for the Detail 2 band, choose Properties, and turn on Associated header and footer bands. Then add objects as desired to the Detail Header 2, Detail 2, and Detail Footer 2 bands. For example, the template shown below has a template for the subreport description (with Template type set to "Subreport Description"), a blue rectangle, and a template for the subreport column headings in the Detail Header 2 band, a lighter blue rectangle and a template for subreport detail fields in the Detail 2 band, and a blue rectangle in the Detail Footer 2 band.
Here's an example of a report with a couple of subreports using this template:
Other notes
To specify that a particular paper size or source is used for all reports using the template, choose Report Properties from the Report menu, click the Page Setup button and select the desired paper size and source in the Page Setup dialog, then click OK. Note that you can force all reports using the template to be output using landscape by choosing Landscape for the orientation; that overrides the Orientation setting for the report. Be sure to turn on the Save printer environment setting before clicking OK to close the Report Properties dialog or these settings aren't saved.
For the page header, you can either use loReport.GetReportHeader() to display both the page header and the filter for the report or loReport.GetReportHeader(.T.) to display only the page header. You can use loReport.GetReportFilter() to display the report filter in its own field.
Once you've finished making changes in the Advanced Report Designer, save the changes using the Save function in the File menu and close the Advanced Report Designer.
Cross-Tab Templates
One thing that's specific for cross-tab reports is an indicator of when a subtotal or total is being output: in that case, _SUBTOTAL or _TOTAL are True. You can use these in Print When expressions for an object to display something only when in a subtotal or total. For example, in the Cross-Tab Gradient template, the rectangle in the Details band has a Print When expression using both _SUBTOTAL and _TOTAL so this rectangle appears only for subtotal and total lines.
Objects in the group header, group footer, and summary bands are ignored when the template is used for a cross-tab report with the exception of a field that has Template type set to Summary total template; the expression of such a field is used for the text of the "totals" object at the end of the report.
You can use the Dynamics tab of the properties dialogs for the various objects in a template to specify how to format the object. For example, in a cross-tab report, you can use a dynamic condition of _TOTAL to format the grand totals line in bold text.
© Keystroke.ca, 2023 • Updated: 10/06/20
Comment or report problem with topic