Unable to set docx table column width using python-docx module

Viewed 33

I have the following code. But when I open copy.docx in Word the table column width is still the original value of 5.25 cm. What am I missing here?

import docx
import docx.shared

colw = docx.shared.Cm(4.5)
d1 = docx.Document("sample-table.docx")

for table in d1.tables:
    for column in table.columns:
        column.width = colw
        for cell in column.cells:
            cell.width = colw

d1.save("copy.docx")
0 Answers
Related