Word Templates in CB 7.1 and Older
|
This Wiki page describes outdated Word Export customization, which has been completely reworked in Codebeamer 7.2. For customization of Word templates look at Word Templates in CB 7.2 - 9.2.
|
Customizing Word Export of Issues
This Section describes about customizing Word Export of issues.
Format of the exported file
The file that is actually exported for Word is
not a native Word document, but an
MHTML
file that Word fully understands.
It consists of multiple so-called parts:
• The main part in the MHTML is a regular HTML document, this is the actual document body.
• The images referenced by the main HTML part are saved into additional parts, one part for each image.
Customizing the content: HTML and CSS
The content of the document body, the document header and the document footer are rendered from regular
Velocity templates
for easy customizability. Making modifications on the templates is totally similar to
customizing the notification emails sent by
Codebeamer. (Thus we strongly suggest that article, as well.)
It's important to understand that what you actually do is modifying an HTML template. You can use most of the HTML formatting capabilities (like colors, font weight, and borders), most of the HTML text constructs (like lists or tables), but not everything. For instance, floating <div>'s will not be understood by Word, as a floating block doesn't make much sense in a word processor.
You can also use CSS, with the same restrictions: exotic visualization, like drop shadows, will be ignored by Word.
The template files are located in the CB_HOME//tomcat/webapps/cb/config/templates/html directory:
requirement-document-export-body.vm | Specifies the body content for the document. |
requirement-document-export-headerfooter.vm | Specifies the document header and footer. The header and the footer. |
requirement-document-export.vm | Specifies the "skeleton" of MHTML. It's very unlikely that you will ever modify it. |
Modify them, save them and export a new document. Codebeamer will pick up your changes immediately.
Word-specific fields
Another interesting feature is that you can use special, non-standard HTML fragments in the templates, which generate fields managed by Word.
You can, for instance, add this snippet to have an intelligent Word-managed TOC in your document:
<p class=MsoToc1>
<!--[if supportFields]>
<span style='mso-element:field-begin'></span>
TOC \o "1-3" \u
<span style='mso-element:field-separator'></span>
<![endif]-->
<span style='mso-no-proof:yes'>Please right-click and choose "Update Field" to initialize this field.</span>
<!--[if supportFields]>
<span style='mso-element:field-end'></span>
<![endif]-->
</p>
Or, you can insert this to have a "17 of 82" style page number (fully managed and recomputed by Word!):
Page <!--[if supportFields]>
<span class=MsoPageNumber><span style='mso-element:field-begin'></span>
PAGE
<span style='mso-element:field-separator'></span></span>
<![endif]-->
<span class=MsoPageNumber><span style='mso-no-proof:yes'>1</span></span>
<!--[if supportFields]>
<span class=MsoPageNumber><span style='mso-element:field-end'></span></span>
<![endif]--> of <!--[if supportFields]>
<span class=MsoPageNumber><span style='mso-element:field-begin'></span>
NUMPAGES
<span style='mso-element:field-separator'></span></span>
<![endif]-->
<span class=MsoPageNumber><span style='mso-no-proof:yes'>1</span></span>
<!--[if supportFields]>
<span class=MsoPageNumber><span style='mso-element:field-end'></span></span>
<![endif]-->
Examples
Modifying the page header and adding your company logo
Modify the "h1" paragraph in requirement-document-export-headerfooter.vm and add a new <img> element where it fits.
Adding further attributes to requirements
Modify this table in requirement-document-export-body.vm and add the fields you want to see in the exported document:
<table class="requirement-props">
<tr><td class="field">Revision:</td><td class="value">3</td></tr>
<tr><td class="field">Priority:</td><td class="value">${requirement.namedPriority.name}</td></tr>
#if(${requirement.status})<tr><td class="field">Status:</td><td class="value">${requirement.status.name}</td></tr>#end
</table>