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:

61d6a999c0c37.png

Created document:

61d6a99ac35cc.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}}.

Template:

> Hi {{name}}!

Module's setup:

61d6a99bd3413.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:

61d6a99d12942.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:

61d6a99e3c9d5.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:

61d6a99f64b00.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 to 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

61d6a9a05de5f.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:

61d6a99f64b00.png

Module's setup:

61d6a9a1ba756.png

Created document:

61d6a9a3454e9.png