w:tc (Table Cell)
Contains the content and formatting properties for a single table cell.
Description
w:tc is a table cell containing one or more block-level elements (paragraphs and/or nested tables). It is defined in ECMA-376 Part 1 §17.4.66.
Every w:tc must contain at least one w:p as its last child. Cell properties are specified in an optional leading w:tcPr element. Cells span multiple columns via w:gridSpan in w:tcPr, and merge vertically via w:vMerge.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
| (none) | — | — | Properties are expressed via the w:tcPr child element. |
Examples
<w:tc>
<w:tcPr>
<w:tcW w:w="2500" w:type="dxa"/>
</w:tcPr>
<w:p>
<w:r><w:t>Cell content</w:t></w:r>
</w:p>
</w:tc>
new TableCell(
new TableCellProperties(
new TableCellWidth { Width = "2500", Type = TableWidthUnitValues.Dxa }),
new Paragraph(new Run(new Text("Cell content"))));
Notes
- The last element in a
w:tcmust always be aw:p(even if empty). Omitting it is a spec violation. - Cells in a vertically merged block that are not the top cell use
<w:vMerge/>(now:val) and still require aw:pchild.