You are on the Xporter Server documentation. If you are looking for Xporter Cloud documentation, you can find it in this page.

In this exercise, you'll learn how to populate a Word template with a table of contents.

Open an empty word document, let's get to the exercise.

Firstly, we are going to create a cover page, you need to go to tab Insert -> Cover Page and select one of your choice.

The Cover Page is populated from the document properties. You can:

(1) Write your desired text directly on the cover page;

(2) Insert it into the correct document property or;

(3) Apply a mapping to the document property.

You'll see examples of this in this exercise example template.

After creating the cover page, the second page is blank. We are going to insert a table of contents. you need to go to tab References -> Table of Contents select the Automatic Table 1.

The table of contents is going to three levels:

The first level is detected by Heading 1

The second level is detected by Heading 2

The third level is detected by Heading 3

Our template will export a list of Bugs, and then a list of Stories (Issue types). These will be our first level on the TOC. For each issue exported, in both issue types, it will be printed its Key, which will be the TOCs second level, and its comments and linked issues, wich will be the TOCs third level.

Below the table of Contents, we are going to insert a page break and continue with our template.

Now we have to insert a title. Name it "Bugs" and set up the style Heading 1. Below it, we are going to create the following section that will list all the issues being exported of the type Bug.

&{for issues|filter=%{'${IssueTypeName}'.equals('Bug')}}

We'll insert a new title here to identify each issue in the TOC. Name it "${Key}" and set the style Heading 2.

We'll want to extract the issue summary, so we need to put on the template, the correspondent mapping.

Now, for each issue, we'll want to export its linked issues. However, we'll only want to print this information in the final document if there are issue links. Insert the following conditional block:

#{if (%{${LinksCount} > 0})}

The title for this iteration can be "Links" and set up the style Heading 3.

Insert the Links table Header:

KeySummaryLink Type

And below it you put the #{for links} or #{for <VariableName>=LinksCount} statement, so the Header is printed only one time.

With that done, you create another table where the Issue Links will be populated:

${Links[n].Key}${Links[n].Summary}${Links[n].LinkType}

Finally close the Links statement using the mapping #{end} and the Conditional Block statement with another #{end}.

Now, we are going to repeat the same process to iterate the issue comments.

Insert the conditional block to know if there are comments on the issue

#{if (%{${CommentsCount} > 0})}

The title for the second iteration can be "Comments" and set up the style Heading 3.

Then the Links table Header:

AuthorBodyDate

And below it you put the #{for comments} or #{for <VariableName>=CommentsCount} statement, so the Header is printed only one time.

With that done, you create another table where the Issue Comments will be populated:

${Comments[n].Author}${Comments[n].Body}${dateformat("yyyy-MM-dd hh:mm"):Comments[n].Created}

Finally close the Links statement using the mapping #{end} and the Conditional Block statement with another #{end}.

We must finish the section of Bugs with &{end}.

We need to repeat the process above, but now for the stories. Start by inserting a page break.

Insert a title named "Stories" and set up the style Heading 1. Below it, We are going to create the following section will list the issues of the type Story.

&{for issues|filter=%{'${IssueTypeName}'.equals('Story')}}

Insert the second level of the TOC with the issue "${Key}" and extract the issue Summary on the next line of the document.

Repeating the previous steps to iterate the issue links and comments, insert:

#{if (%{${LinksCount} > 0})}

The title for this iteration should be "Links" and set up the style Heading 3.

Insert the Links table Header:

KeySummaryLink Type

And the #{for links} or #{for <VariableName>=LinksCount} statement. Insert the table to export the links:

${Links[n].Key}${Links[n].Summary}${Links[n].LinkType}

Close the iteration with #{end} and the conditional block with another #{end}.

Insert the comments sections:

#{if (%{${CommentsCount} > 0})}

The title for this iteration should be "Comments" and set up the style Heading 3. Insert the Comments table Header:

AuthorBodyDate

And the #{for comments} or #{for <VariableName>=CommentsCount} statement. Insert the table to export the comments:

${Comments[n].Author}${Comments[n].Body}${dateformat("yyyy-MM-dd hh:mm"):Comments[n].Created}

Close the iteration with #{end} and the conditional block with another #{end}.

Finish the section of Stories with &{end}.


We have completed our template. However, you need to go to the table of contents. The table is empty, so we must do these steps:

  1. Select the table of contents
  2. Right click and click on Updated Field
  3. Update entire table
  4. Click on OK.

The table of contents will show us the three levels that you have created along of template.

We can create more levels using different styles.

Also, you can iterate more iterations for example(Attachments, worklogs, etc..)

Below there is a sample of how the mappings will be displayed in a Word template:


This Template has:

  • A header with an image
  • Headings
  • Text styling
  • Table
  • Table of Contents
  • Cover Page

Below there is a sample of how the generated file will be populated:


If you like this exercise, please share your opinion on the page by just leaving a comment or a (thumbs up). Your opinion is very important to us.

Thank you in advance.

Enjoy our product. (big grin)

Here's the Exercise 4 related files:

FileDescription
Exercise4Template

Exercise 4 Sample Template file

Exercise4GeneratedExercise 4 Sample generated file
  • No labels