-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
In order to provide the least surprising initial behavior
As a developer using python-docx
I would like a table inserted using add_table()
to be serviceable in both Word and LibreOffice without further adjustment.
Related to #75. Default table added with Document.add_table()
runs off the page in LibreOffice, although it's fine in Word. Rendering differences aside, it would be better if it produced consistent results across the two clients.
The solution is to add column widths, e.g. <w:gridCol w:w="1440"/>
as well as matching cell widths, e.g. <w:tcW w:w="1440" w:type="dxa"/>
for each cell in each column. This is consistent with what Word does when adding a new table from the ribbon.
Column widths should be evenly distributed across the page width. For example, a 4-column table inserted into a page with 8 inches between the margins should have four columns 2 inches wide each.