How Do I Get Rid Of The Default Styling On A Table Object In A Python-docx Generated Word Document?
Per the python-docx documentation the following code generates a simple table with three columns: table = document.add_table(rows=1, cols=3) hdr_cells = table.rows[0].cells hdr_cel
Solution 1:
The best bet for this sort of thing in the current version is to apply a table style, for example:
table.style = 'LightShading-Accent1'
It's possible to modify the table styles in Word in the ways you describe, e.g. header font, row banding, etc. So you can modify one of the existing styles to suit or create your own.
Make sure you study these two pages in the python-docx documentation to understand how to make styles available in your document at run time:
http://python-docx.readthedocs.org/en/latest/user/styles.html http://python-docx.readthedocs.org/en/latest/user/documents.html
Solution 2:
you need to know styles in your document
styles = document.styles
for s in styles:
print(s.name)
then try this
table2 = document.add_table( rows=15, cols=15,style='Table Grid')
you can change style to whatever your document supports with
(style='Table Grid')
python 3.4 docx 0.8.6
Post a Comment for "How Do I Get Rid Of The Default Styling On A Table Object In A Python-docx Generated Word Document?"