Skip to main content

Microsoft Word Templates

Getting started with Microsoft Word Templates

Microsoft Word Templates enables you to merge data provided by various services with templates and produce Microsoft Word documents as a result.

Template:

1word.png

Created document:

2word.png

Template creation

A Template is a regular Microsoft Word document (.docx file) with special tags in its text that determine where and how to merge/fill in data. There are three types of tags: Simple value, Condition and Loop or section.

Simple value

A Simple value tag is simply replaced with a corresponding value. The tag's name corresponds to the Key field's value, which is placed inside double curly braces: e.g. {{name}}.

Note

The Microsoft Word Templates app accepts only single-line plain text for replacement values. When adding line breaks, they will be viewed as spaces and won't affect the formatting of the text.

Template:

> Hi {{name}}!

Module's setup:

3word.png

Created document:

> Hi Petr!

Condition

A Condition tag enables you to wrap certain parts of a text that should be rendered conditionally. To wrap the conditional text, place it between the opening and closing tags. The name of the opening tag is prepended with a hash sign #, the name of the closing tag is prepended with a slash /.

Template:

> {{#hasPhone}}Phone: {{phone}} {{/hasPhone}}
> {{#hasEmail}}Email: {{email}} {{/hasEmail}}

Module's setup:

4word.png

Created document:

 > Phone: 123456

Loop or section

A Loop or section tag enables you to repeat parts of a text. Similarly to the Condition tag, to wrap the repeated text, place it between the opening and closing tags. The name of the opening tag is prepended with a hash sign #, the name of the closing tag is prepended with a slash /.

When using loops, you can choose to employ either the Fill out a document module or the Fill a document with a batch of data aggregator module.

Fill out a document

If you employ Fill out a document module, the content of the field Value has to be an array of collections, where:

  • Each collection corresponds to one data entry and contains one item entry

  • Item entry contains a collection with two items key and value

  • Item key contains the tag's name

  • item value contains the tag's value

Template:

> {{#contact}}
>     {{name}}, {{phone}}
> {{/contact}}
               

Module's setup:

5word.png

Created document:

> Jan Toman, 1234
> Eduard Salo, 7899999
               

You can also execute a loop to populate a table. The example below shows how to create such table in a template:

6and8word.png

Fill a document with a batch of data

If your data entries come as separate bundles, you may prefer to employ the Fill a document with a batch of data aggregator module. You can employ this module also if your data entries come as an array - just employ the iterator module to transform the content of the array into a series of bundles.

The main advantage of the Fill a document with a batch of data module is that it enables you to easily setup the structure required for the Value field and map items to each value item. In contrast to the Fill out a document module, the field Values contains only a single entry, the actual entries will be created and populated for each incoming bundle. The template will be produced after all input bundles have been processed. The aggregator module is useful, especially when creating lists or reports.

Example: Export Google Contacts into a table

7word.png

The first module loads the template. The next module retrieves all contacts from the specified group in Google Contacts. The aggregator module then aggregates all values retrieved from Google Contacts and merges them into the template. Finally, the last module will save the filled template to a desired location.

Template:

6and8word.png

Module's setup:

9word.png

Created document:

10word.png