Releases RSS Feed
Compatibility : nodejs and browser

Summary (version 3.3.1) Buy styling module

This module makes it possible to edit style of table cells or paragraphs conditionnaly (background-color, ...).

This module is available as part of the docxtemplater ENTREPRISE plan.


Style Module

This module exposes multiple tags to dynamically change the style of a given paragraph or table cell for example.

The current tags are :

  • {:stylecell style} To style a cell
  • {:stylepar style} To style a paragraph
  • {:stylerow style} To style a whole row in a table


You will need docxtemplater v3: npm install docxtemplater

Install this module with npm install --save "$url"


Your docx should contain the text: {:stylecell style}.

const StyleModule = require("./es6");
const styleModule = new StyleModule();
const PizZip = require("pizzip");
const zip = new PizZip(content);
const doc = new DocxTemplater()
        style: {
            cellBackground: "#00ff00",
            textColor: "white"
            fontFamily: "Calibri"

const buffer = doc.getZip().generate({compression: "DEFLATE", type: "nodebuffer"});

Paragraph Styling

To style a paragraph, you can use following styles :

    "cellBackground": "#00ff00",
    "textColor": "white",
    "pStyle": "Heading",
    "fontFamily": "Calibri"

After installing the module, you can use a working demo by running node sample.js.



Update to make module work in the browser


Add support for pptx

Add {:stylerow} tag

Require docxtemplater 3.17.6


Declare supportedFileTypes, which allows to use this module with the new docxtemplater constructor which was introduced in docxtemplater 3.17.


  • Add support for changing pStyle in {:stylepar}


  • Update browser build to use XMLSerializer instead of xmldom

  • Use requiredAPIVersion


  • Move docxtemplater from devDependencies to dependencies

Explanation : On some versions of npm (notably 5.8.0), when having a package containing docxtemplater-styling-module, the installation will generate a tree of node_modules that puts the module on a level where it has no access to docxtemplater. By explicitly asking it as a dependency, this issue is avoided.


  • Make module compatible with docxtemplater version 3.5 and below.

Explanation : Recently, the scopemananger API (internal API) has changed, this new version of the footnotes module makes the module work with both versions newer than 3.6 and older than 3.6 of docxtemplater.


Add meta context argument to custom parser with information about the tag for each types of tags


  • Add the {:stylepar style} tag to change the paragraph style

  • Add support for fontFamily: "Calibri"

  • Refactor module.prefix into an object {cell: ':stylecell', paragraph: ':stylepar'}


Initial release

Edgar Hipp

I'm the creator of docxtemplater. I work on making docxtemplater great since 2013.