Wednesday, January 26, 2022

Python-docx

The amount that I have learned about they python-docx library could fill a book. Fortunately all of that information is still online where I originally found it. For the purposes of closing tabs, here are some selected lessons and links:
In word tables, to set cell sizes and other cell properties it isn't really set up to do it like a person would and set properties by row or column. Most properties are set at the individual cell number, but it's a computer, make it iterate through all the cells in a row and column to get the desired look. https://stackoverflow.com/questions/43051462/python-docx-how-to-set-cell-width-in-tables
Here's the online python-docx docs page about tables. Doesn't fully illuminate the ideosyncracies, mostly a general explainer on how docx is xml and what tables look like in this particular xml. Apparently there are only two table-wide properties, because everything else is cell properties. The table-wide properties are alignment and fixed-width vs auto-width columns: https://python-docx.readthedocs.io/en/latest/dev/analysis/features/table/table-props.html