I am trying to apply a style to a paragraph in a document using the python-docx module. I can write new text, but I cannot apply a different style to a previously-written paragraph.
Here is an example:
x = docx.Document('Sample.docx')
x
Out[81]: <docx.api.Document at 0x121cebed0>
x.paragraphs[2].style
Out[82]: 'Normal'
x.paragraphs[2].style = 'Title'
x.paragraphs[2].style
Out[84]: 'Normal'
I cannot tell from the documentation whether this should work or not. It seems to indicate that paragraph style is writable, but there is no example of this use case in the documentation.
Please let me know whether this is my problem, or if the functionality is not implemented yet.