a:tbl (DrawingML Table)
Defines a table structure in DrawingML with rows, columns, and cell content.
Parent elements
Description
a:tbl defines a table in DrawingML content (presentations, documents, or worksheets). It is defined in ECMA-376 Part 1 §20.1.2.23.
a:tbl structure:
a:tblPr– Table properties (borders, alignment, background)a:tblGrid– Column definitions and widths- One or more
a:tr– Table rows, each containing cells
DrawingML tables differ from WordML (w:tbl) and SpreadsheetML tables; they are primarily used for tabular content in presentations and embedded documents.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
| (none) | — | — | a:tbl has no attributes; all configuration is via child elements. |
Examples
Simple 2×2 Table
<a:tbl>
<a:tblPr/>
<a:tblGrid>
<a:gridCol w="1828800"/>
<a:gridCol w="1828800"/>
</a:tblGrid>
<a:tr h="914400">
<a:tc>
<a:txBody><a:bodyPr/><a:p><a:r><a:t>Header 1</a:t></a:r></a:p></a:txBody>
<a:tcPr/>
</a:tc>
<a:tc>
<a:txBody><a:bodyPr/><a:p><a:r><a:t>Header 2</a:t></a:r></a:p></a:txBody>
<a:tcPr/>
</a:tc>
</a:tr>
<a:tr h="914400">
<a:tc>
<a:txBody><a:bodyPr/><a:p><a:r><a:t>Data 1</a:t></a:r></a:p></a:txBody>
<a:tcPr/>
</a:tc>
<a:tc>
<a:txBody><a:bodyPr/><a:p><a:r><a:t>Data 2</a:t></a:r></a:p></a:txBody>
<a:tcPr/>
</a:tc>
</a:tr>
</a:tbl>
using DocumentFormat.OpenXml.Drawing;
var table = new Table();
var tableProperties = new TableProperties();
table.Append(tableProperties);
// Define column grid (2 columns, each 1.828 mm = 1828800 EMUs)
var tableGrid = new TableGrid();
tableGrid.Append(new GridColumn { Width = 1828800 });
tableGrid.Append(new GridColumn { Width = 1828800 });
table.Append(tableGrid);
// Header row
var headerRow = new TableRow { Height = 914400 };
// ... add cells with text ...
table.Append(headerRow);
// Data row
var dataRow = new TableRow { Height = 914400 };
// ... add cells with text ...
table.Append(dataRow);
Table with Formatted Cells
<a:tbl>
<a:tblPr>
<a:tableStyleId>{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}</a:tableStyleId>
</a:tblPr>
<a:tblGrid>
<a:gridCol w="2743200"/>
</a:tblGrid>
<a:tr h="914400">
<a:tc>
<a:txBody>
<a:bodyPr/>
<a:p>
<a:r>
<a:rPr lang="en-US" sz="2400" b="1"/>
<a:t>Bold Header</a:t>
</a:r>
</a:p>
</a:txBody>
<a:tcPr>
<a:solidFill><a:srgbClr val="4472C4"/></a:solidFill>
</a:tcPr>
</a:tc>
</a:tr>
</a:tbl>
var table = new Table();
var tableProperties = new TableProperties
{
TableStyleId = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"
};
table.Append(tableProperties);
var tableGrid = new TableGrid();
tableGrid.Append(new GridColumn { Width = 2743200 });
table.Append(tableGrid);
var row = new TableRow { Height = 914400 };
var cell = new TableCell();
// Add text with formatting
var tcPr = new TableCellProperties();
tcPr.Append(new SolidFill(new RgbColorModelHex { Val = "4472C4" }));
cell.Append(tcPr);
row.Append(cell);
table.Append(row);
Notes
- Width values in
a:gridColare in EMUs (English Metric Units): 914400 EMUs = 1 inch. - Row height (
hattribute) is also in EMUs. Omit for auto-height. - Each
a:tr(row) must have the same number of cells as defined in the grid. - Cells are formatted via
a:tcPrwhich can include fills, borders, and text properties. - DrawingML tables are separate from WordML tables (
w:tbl) and have different element structures.