Generate Word document with chart

Hi all, I know that there are some (licensed) possibilities to create Word documents based on a template that uses variables to put data out of the Mendix db into the template and export this filled Word template. My question is; can any of these already existing solutions also generate a graph (for instance stacked bar) into this template and export it with the graph, based on data inside the Mendix db? So, no image, but an actually on the fly generated graph. I hope there is a solution out there already, else I would have to build it from scratch...  
5 answers

Hi Ivo,

I haven’t done this with Mendix’s document templates yet, but here are a few thoughts that might be helpful:

  1. If you are able to get the graphs html as a string, you could insert it as a placeholder onto the document. I’ve done this with images and full html documents so I would imagine this would work with a chart built from html. If its a fairly simple chart you may be able to manipulate the html in a microflow using find and replace.
  2. I remember one of the Mendix charts widget example projects on github showed how you can call a rest service of your chart configuration and have an image returned of the chart. I know in your question you said no images but it would still be generated on the fly. I think this was for the chartjs library, and if I remember correctly this might be a paid service. But they do offer a javascript library that does the same thing, so you could build this service yourself outside of Mendix.
  3. Another option (that is paid) would to check out the Aspose words for Java library. I’ve used this in the past to replace tokens in a word document, but I just saw that they do have some support for charts. It may be worth taking a look to see if those charts fit your needs. Also although Aspose is paid, its a one time fee vs a yearly subscription. I’ll link the library at the bottom.


Hope this helps! I’ll add some comments if I think of anything else.



Aspose Library


In the end I went for creating my own solution, see app store now :)



I believe the WordTemplater from the Mendix Appstore can achieve this. We use it to generate a lot of pie graphs based om te data from the Mendix application.


WordTemplater in the Mendix Appstore


Another (also paid) solution can be our Document Generation 4 Mendix module.


And this one:

The graphs can be in Word or in Excel. Yes it is an paid module but the license is only $200,-.

See also