w:tblLayout (Table Layout)
Specifies whether a table's column widths are fixed or determined dynamically by content (autofit).
Parent elements
Description
w:tblLayout controls how the table renderer calculates column widths. In fixed layout, the declared w:tblGrid widths are honoured regardless of content. In autofit layout, columns expand or shrink to fit their content, up to the table width.
It is defined in ECMA-376 Part 1 §17.4.52.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:type |
ST_TblLayoutType |
fixed, autofit |
Layout algorithm used. |
Values
| Value | Description |
|---|---|
fixed |
Column widths are fixed to the values in w:tblGrid; content wraps or truncates. |
autofit |
Column widths adjust to fit cell content within the available table width. |
Examples
<w:tblPr>
<w:tblLayout w:type="fixed"/>
</w:tblPr>
using DocumentFormat.OpenXml.Wordprocessing;
var tblPr = new TableProperties(
new TableLayout { Type = TableLayoutValues.Fixed }
);
Notes
- Fixed layout (
fixed) is the default for Word tables with explicit column widths. - Autofit (
autofit) corresponds to Word’s “AutoFit to Contents” option. - When
w:tblWusesw:type="auto", the table layout is effectively autofit regardless ofw:tblLayout.