I have code that writes stuff to cells in a table in a .docx file. The table already has pre-set formatting (e.g. size 16 Arial font, align right etc.). However, when python writes to the table, the formatting reverts to word's default (size 12 times new roman, alighn left).
Is there some function within the docx module to merge the formatting when writing to the table?
Example code:
from docx import Document
doc = Document('table.docx')
table = doc.tables[0]
table.cell(0, 0).text = str('blahblah')
doc.save('table.docx')
The long way would be to specify in the code what format to write it in but this can be really tedious having to write code for every single cell in a table that has different formatting. It's far easier to set the formatting in word than it is to write the code for it in python.