Report Studio has predefined report templates that you select from when you create a new report. You can create your own custom report templates and make them available too.
To add a custom report template, you must
![]() | |
![]() | |
![]() | |
![]() |
Note: When you reinstall or upgrade Cognos 8,
the changes associated with the custom report templates are not
migrated. You may need to redo the above steps .
There is no template object in Cognos 8. Instead, you can use any report specification as a report template. You can create the report specification for your custom report template by using Report Studio, an XML editor, or a text editor.
Open Report Studio.
Create a new report.
For more information, see the Report Studio User Guide.
From the File menu, click Convert to Template.
From the Tools menu, click Copy Report to Clipboard to save the report specification XML.
Paste the report specification into an XML editor or text editor.
Delete the following information, which Report Studio adds to the XML file and which is not necessary for the template:
The xmlns attribute of the report element.
The template attribute of the report element.
The value of the name attribute of the query element. Delete the value, but leave the double quotation marks.
The value of the name attribute of the page element. Delete the value, but leave the double quotation marks.
The value of the refQuery attribute of the list element.
Add a new template element as a parent of the report element.
Add a name attribute for the template element.
The name you enter appears as the name of the template in the new report dialog box.
Save the report specification.
Here is an example of the initial part of a report specification created in Report Studio. The portions to delete appear in bold.
<template name="CognosList"> ... <report xmlns="http://developer.cognos.com/schemas/report/4.0/" expressionLocale="en" template="true"><!--RS:8.2--> <queries> <query name="Query1"> <source> <model/> </source> <selection/> </query> </queries> <layouts> <layout> <reportPages> <page class="pg" name="Page1"> <pageBody class="pb"> <contents> <list class="ls" refQuery="Query1"> <style> <CSS value="border-collapse:collapse"/> </style> </list> ................. </report> </template>
Open the report specification in an XML editor or text editor.
Add the elements you want to appear in your template.
For more information, see the Developer Guide.
Add a new template element as a parent of the report element.
The name you enter appears as the name of the template in the new report dialog box.
Add a name attribute to the template element.
The name you enter appears as the name of the template in the new report dialog box.
Save the report specification.
The Templates.xml file contains the templates that you select from when you create a new report in Report Studio. You must add your custom report template to this file.
Open the templates.xml file.
This file is located in the c8_location/webcontent/pat/res directory.
Copy the XML code for the custom report template into the file.
The template element must be a child element of the xmlFragment element.
Add the <modelPath/> directive.
Here is an partial example of the XML for the template created
in the previous task .
<xmlFragment> template name="CognosList"> <report> <modelPath/> ... </template> </xmlFragment>
Save and close the file.
You can create an icon that you want to represent the custom report template. The icons in the new report dialog box are 32 x 32 pixels .gif images.
You can use any graphic editor to create the icon.
Create the icon you want.
Copy the image file into the c8_location/webcontent/pat/images directory.
The Resources.xml file defines the content of the new report dialog box in Report Studio. You must modify this file by adding the information that refers to the custom report template.
For the listItems element, you add a new listItem element that represents the new template. The listItem element must have the following attributes.
Attribute | Description |
idsLabel | Specifies an ID that refers to a Report Studio string resource file located in the c8_location/webcontent/pat/res directory, and a label for the template that appears in the new report dialog box. Use this attribute when you want to add the ID and label for your custom template in the string resource file. You use the string resource file when you want the label to appear in multiple languages. |
label | Specifies a label for the template that appears in the new report dialog box. Use this attribute instead of the idsLabel attribute for the custom template when you do not want the label to appear in multiple languages, which eliminates the need to use the string resource file. |
icon | Specifies an image file associated with the template, located in the c8_location/webcontent/pat/images directory. The image appears as an icon in the new report dialog box. Use a previously created image file for the custom report template. |
Open the Resources.xml.
This file is located in the c8_location/webcontent/pat/res.
Add a new listItem element using the label or idsLabel attribute for the custom report template.
Here is an example of the edited file:
<listView id="text-align"> <listItems> <listItem value="" idsLabel="IDS_PROPVAL_DEFAULT" smallIcon="default_prop_value.gif"/> <listItem value="left" idsLabel="IDS_PROPVAL_TALIGN_LEFT" smallIcon="hal/images/btn_align_left.gif"/> <listItem value="center" idsLabel="IDS_PROPVAL_TALIGN_CENTER" smallIcon="hal/images/btn_align_center.gif"/> <listItem value="right" idsLabel="IDS_PROPVAL_TALIGN_RIGHT" smallIcon="hal/images/btn_align_right.gif"/> <listItem value="justify" idsLabel="IDS_PROPVAL_TALIGN_JUSTIFY" smallIcon="hal/images/btn_align_justify.gif"/> </listItems> </listView>
Save and close the file.
You must now restart Report Studio for the custom report template to appear in the new report dialog box.