Word Template Demo Project

Category: Samples
Subcategory: Examples



* Generate fully styled Word documents populated with data from your Mendix application!

* Dynamically populate rich text fields, images, item lists (bullets) and tables with your Mendix data.

* Even Excel graphs (Stacked Bar / Line) based on Mendix data are included!

* No need for Aspose or other paid third party license; pure Mendix and Java!


Demo urlhttps://wordexporter127-sandbox.mxapps.io/index.html?profile=Responsive


Generate fully styled Word documents populated with data from your Mendix application! Even Excel graphs based on Mendix data are included! No need for Aspose or other paid third party license; pure Mendix and Java!

Typical usage scenario

When your Mendix app needs to be able to generate Word documents with proper styling as well as potential Excel graphs based on data from your Mendix application.


  • The Word document is based on a template, maintained in Word;
  • All styles from the Word document (font size, color, etc) will be maintained;
  • The Word document can be updated with data coming from your Mendix app, preserving all styling. This works for plain text and when used in bullets / headers / tables as well;
  • If your Word document has Stacked Bar Chart templates, the Stacked Bar Charts can be updated with data coming from your Mendix app! Currently only Stacked Bar Charts and Line Charts are included;
  • Exporting to PDF is not fully working yet, see limitations.

Limitations (not included)

  1. Other types of Chart templates than Stacked Bar and Line Charts;
  2. PDF export is not working perfectly yet. For plain text it will work, but Charts are not included and table margins are looking off;

Supported scenarios 

  • Export to Word replacing tokens (=BookmarkValue) in the template for Mendix values (=ReplacementValue), preserving font styles;
  • Adding custom tables, rich text, (un)ordered lists and images
  • Adding one or many Stacked Bar and/or Line Charts with data form Mendix.


The solution uses quite some jar files. Be aware those can conflict with the Mendix modules also using Apache POI jars, like the Excel Importer and Excel Exporter modules.

  • For replacing words in Word:
    • poi-4.1.2 poi-ooxml-4.1.2
    • poi-ooxml-schemas-4.1.2
  • For updating Excel charts to in Word templates the jars:
    • xmlbeans-3.1.0
    • commons-collections4-4.3
    • commons-compress-1.18
  • For transforming Word docs to PDF the jars:
    • fr.opensagres.poi.xwpf.converter.core-2.0.2
    • fr.opensagres.poi.xwpf.converter.pdf-2.0.2
    • fr.opensagres.xdocreport.itext.extension-2.0.2
    • itext-2.1.7 ooxml-schemas-1.4


This is a test project which comes with data, created by an after startup microflow. If the database is empty it will create both the entities which are needed for proper demonstration of the power of the module:

  1. WordReplacer: Mendix entities which are used to change the content of the Word file. The Java action ‘JA_WordDoc_Generate’ will search the Word file and if hits of ‘BookmarkValue’ are found, change them to the content of ‘ReplacementValue’;
  2. Chart / ChartValue: Mendix entities used to populate the Excel Stacked Bar Chart categories and series. It can be confusing to understand what categories and series are within the context of this module, hence you should really check with the example entities created within this module in after startup. Send an e-mail to ivo.sturm@firstconsulting to get the example word document which is needed for step 1.



  1. Run the test project;
  2. Read the content in the group boxes on the home page:
    1. Instruction
    2. Features
    3. Dependencies
    4. Limitations
  3. Step 1: Upload the Word template file which can be found in the resources folder of this project
  4. Step 2: If needed, change the Word file, as well as change the bookmark values;
  5. Step 3: If needed, change the Excel Charts in the Word file, as well as change the series and categories values;
  6. Step 4: Export the Word document with updated Word and Excel content from your Mendix application.

For a demo, see https://wordexporter127-sandbox.mxapps.io/index.html?profile=Responsive

If in doubt on what is going wrong, proper Trace logging is added; set the Log level of the ‘Word’ node to Trace to see what is happening within Mendix!





Version: 3.1.0
Framework Version: 8.18.1
Release Notes: * Fixed bug where for Word replacements the first row of tables was deleted (if not used for positioning Table data, Item Lists, Rich Text * Minor code improvements
Version: 3.0.0
Framework Version: 8.18.1
Release Notes: * Upgraded to Apache POI 4.1.2 library * Rich Text: Added Rich Text item support via ckEditor * Tables: Added support for different Cell styling * Images: Support for image exports via Rich Text. Only ckEditor widget supports this, RichText doesn't. * List Items: Added font styling within Item List elements * Charts: Only plots the series that are added via Mendix. If less series in template, no problem, the Java actio will add them, if more series in template, the java action will remove those. * Charts: Changed ChartValue.CategoryValue attribute from Integer to Decimal * Template: Multiple templates can now be managed. Only one can be the active template and templates can be toggled to (in)active.
Version: 2.2.0
Framework Version: 7.23.7
Release Notes: * Added support for restarting the numbering in the Word document if the document contains multiple numbered/item lists. By default a new list now starts with it's own new range * Added support for up to three levels in both bullet and numbered lists. The bullet list uses the Wingdings fonts letter l (zero-th level), m (first level) and s (second level) for filled bullet, open bullet and diamond. * Added new template (v2.2) in the resources folder to demonstrate these new features.
Version: 2.1.0
Framework Version: 7.23.7
Release Notes: Added possibility to add one or more line breaks in the text which replaces the token/bookmark value. Use
in your ReplacementValue to create a new line.
Version: 2.0.2
Framework Version: 7.23.7
Release Notes: Minor fix for unsupported UTF-8 character in Java code.