I am using python 2.7 with docx and I would like to change the background and text color of cells in my table based on condition.
I could not find any usefull resour
Taking from Nikos Tavoularis answer I would just change the shading_elm_1 declaration, as if you include the cell color in a loop for instance things might get messy.
As such, my suggestion would be:
from docx.oxml.ns import nsdecls
from docx.oxml import parse_xml
table.rows[0].cells[0]._tc.get_or_add_tcPr().append(parse_xml(r' '.format(nsdecls('w'))))