Cell Shading (cellbg)

How to shade cells conditionally with Jinja2

Cells in a .docx table can be conditionally shaded by passing a variable (such as a namespace) to the cellbg command that has the hex value for the desired color (with no hash symbol).

In this example, we establish the namespace "dd" and declare dd.namespace to equal the hex value for a shade of blue

{%p set dd=namespace(color=”4472C4”) %}

Then in our .docx template, we create a cell that uses this variable to shade the cell