You are currently offline, serving cached version

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

Usage (nodejs)

const StyleModule = require("./es6/index.js");
const styleModule = new StyleModule();
const PizZip = require("pizzip");
const zip = new PizZip(content);
const doc = new Docxtemplater(zip, { modules: [styleModule] });
        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.



Use @xmldom/xmldom instead of xmldom, see this github issue


Generate files in built with correct filename In previous versions, the filename was always build/docxtemplater.js. Now the filename is error-location-module.js The .min.js file is also created now.


Add typescript definitions for public API


Move webpack from dependency to devDependency (which triggered an error during installation on node version 10)


Internal change to allow to match tags with non-breaking space.

When entering Ctrl+Shift+Space, a "non-breaking" space is created.

When using a non-breaking space in the tag {:stylecell style}, the tag would not be replaced correctly.


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