Word Report Template

About the template

Use the Word report template to create a customized report. The template uses Word merge fields to get the data that you need. The template is designed for docx files and does not support doc. Here a few tips to get started:
  • To insert merge fields in Microsoft Word, click Insert > Quick Parts > Field > MergeField or click Ctrl+F9.
  • In order to edit a merge field, right click the field and then select Edit Field.
  • You can mix and match standard text in addition to merge fields in your report.
  • Merge fields take the following form: « value ».

General Report Information

The following contains data you may want to use in your report header:

Field Description
${report.name} The name of the report.
${report.projectName} The name of the project where the report is executed.
${report.description} The description of the report.
${report.executedBy} The login name of the user who executed the report.
${report.generatedOn} The date and time when the report was executed.
${report.generatedOnWeek} The week number of when the report was executed.

Accessing Data

The following sections describe how to access and display different data for your report.

By Index
By Name
In Lists
A typical use case would be to iterate through each row and show the column information for every row. To get a list of data, do the following:
«[#list rows as r]»
«${r.TestDefID}» - «${r.TestName}»

The beginning of the loop is defined by [#list rows as r] and the end by [/#list]. The row data within the loop is referenced with r which allows you to get Test Name within the loop by referencing it with ${r.TestName}.

The above example would iterate through all rows and the rendered report would show a list of tests with their id and their name.

In Tables
Defining the start and end of a loop within a table row requires an additional command to continue iterating within the table. You have to place the list command for the loop into the first column of your table and preface it with @before-row. You need to use @after-row to complete the list. The following table shows how to do this.
«${headers[3]}»|«${headers[3].@name}» «${headers[4]}»|«${headers[4].@index}»
«@before-row[#list rows as r]»«${r.ReqName}»«@after-row[/#list]» «${r.ReqDescription.@html}»
Headers and HTML
  • Headers of the data can be accessed with a merge field named headers.
  • Headers can be displayed in different ways by appending .@elementName or .@name or .@index.
  • Some Silk Central data, like many Description fields, are stored as HTML. If you want to display your HTML-encoded text based on its tags, append the attribute .@html. If you don't add this attribute, you will still see the text, but it will contain the HTML markup. For example: if your source data is <b>My report description</b> and you use .@html, you will see My report description. Otherwise, you will see: <b>My report description</b>. The following HTML tags are supported: <b>, <strong>, <i>, <u>, <br>, <p>, and <a>.
Subreports can be accessed with the keyword sub. Append the number of the subreport that you want to access, for example sub1, sub2, etc.
Example: If ProjectID is in the first column of your main report, refer to it with «${rows[0].ProjectID}». If TestID is in the first column of the first subreport, refer to it with «${sub1.rows[0].TestID}». To iterate through all rows of the first subreport and show the TestID column and the second column:
«[#list sub1.rows as sr]» 
  «${sr.TestID}» «${sr.cols[1]}»


Why does my report show wrong data?
Are you referencing columns by their index? If yes, be aware that the first column is referenced by index 0 and not by 1.
Why do I get an error mentioning a specific field when downloading my report? I don't see this field in my template?

You may have changed the label of a field but the mail merge reference still has its original value. For example, you may receive an error message that the field ${r.requirementName} doesn't exist. In your document you see the field ${r.reqName}. When you right click this field and select Edit Field, you will see that the reference is still ${r.requirementName}. Don't forget to change mail merge fields via Edit field.

Sample Report

The following sample Word report shows a report with manual tests containing steps.

Note: You cannot copy and paste this sample as is. It is designed to show you different ways to use reporting code for the various sections in a report. The sample shown below is included in the Report Templates as ManualTestResults.docx.
Report generated: «${report.generatedOn}» «${report.generatedOnWeek}»

Project Name          «${report.projectName}»
Report Description    «${report.description}»
Report Executed By    «${report.executedBy}»

«[#list rows as r]»«[#assign firstRow=(r_index==0 || rows[r_index-1].ManualTestDefID != r.ManualTestDefID)]»«[#if firstRow]»


Status: «${r.StatusName}» 

Planned Time [hh:mm]: «[#if r.PlannedTime!="null"]»«${r.PlannedTime}»«[#else]»00:00«[/#if]»
Used Time [hh:mm]: «[#if r.UsedTime!="null"]»«${r.UsedTime}»«[#else]»00:00«[/#if]»
Build: «${r.BuildName}»
Version: «${r.VersionName}»
Execution Plan: «${r.ExecDefName}»
Changed By: «${r.ChangedBy.@text}»
Changed On: «${r.ChangedAt.@text}»

«[/#if]»«[#if r.StepName != "null"]»«[#if firstRow]» Test Step Details:«[/#if]»
Step Name: «${r.StepName}»
Description: «${r.StepDescr.@html}»
Status: «${r.StepStatus}»
Result Info: «${r.StepResultInfo.@html}» 
Expected Result: «${r.ExpectedResult.@html}»