w:tbl (Table)
Container for a table consisting of table properties, a table grid definition, and one or more table rows.
Description
w:tbl is the root element for a table in a WordprocessingML document body. It is defined in ECMA-376 Part 1 §17.4.38.
A table contains an optional set of table-level properties (w:tblPr), a table grid definition (w:tblGrid), and one or more rows (w:tr). Tables can be nested inside table cells to arbitrary depth.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
| (none) | — | — | All table properties are expressed via child elements w:tblPr and w:tblGrid. |
Examples
<w:tbl>
<w:tblPr>
<w:tblW w:w="5000" w:type="pct"/>
</w:tblPr>
<w:tblGrid>
<w:gridCol w:w="2500"/>
<w:gridCol w:w="2500"/>
</w:tblGrid>
<w:tr>
<w:tc><w:p><w:r><w:t>Cell A</w:t></w:r></w:p></w:tc>
<w:tc><w:p><w:r><w:t>Cell B</w:t></w:r></w:p></w:tc>
</w:tr>
</w:tbl>
var table = new Table(
new TableProperties(
new TableWidth { Width = "5000", Type = TableWidthUnitValues.Pct }),
new TableGrid(
new GridColumn { Width = "2500" },
new GridColumn { Width = "2500" }),
new TableRow(
new TableCell(new Paragraph(new Run(new Text("Cell A")))),
new TableCell(new Paragraph(new Run(new Text("Cell B"))))));
Notes
- Every table cell (
w:tc) must contain at least one paragraph (w:p) as its last child. - Tables must be immediate children of
w:body,w:tc,w:hdr, orw:ftr; they cannot appear insidew:p.