OfficeOpenXML.com
 

Wordprocessing Tables

Related Open Office/ODF Discussion
Properties

Table-wide properties are specified in <tblPr>. Each property is a child element of <tblPr>, and they affect all rows and cells in the table, though they can be overridden by table-level exception, row-level, and cell-level properties.

<w:tblPr>
<w:tblW w:w="0" w:type="auto"/>
<w:jc w:val="end"/>
</w:tblPr>
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.60.

The most commonly used properties are shown below:

Elements/Properties:

ElementDescription
jc See Table Alignment.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.29.
shd See Table Shading.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.32.
tblBorders See Table Borders.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.39.
tblCaption See Table Captions.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.41.
tblCellMar See Table Cell Margins.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.43.
tblCellSpacing See Table Cell Spacing.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.46.
tblInd See Table Indent.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.51.
tblLayout See Table Layout.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.53.
tblLook See Table Conditional Formatting.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.56.
tblOverlap See Floating Tables - Overlapping Tables.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.57.
tblpPr See Floating Tables.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.58.
tblStyle

Specifies the style ID of the table style if a table style is to be used to format the table. See Defining a Style - Table Styles. Table styles are applied after document default styles, so they override the defaults, but all other style types are applied after the table styles, so they override the table style. In the sample below, a table style is referenced, but there is also direct formatting applied for the table justification.

<w:tblPr>
<w:tblStyle w:val="TestTableStyle"/>
<w:jc w:val="center"/>
</w:tblPr>
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.63.
tblStyleColBandSize

This element is applicable to a <tblPr> within a table style. Tables styles can have conditional formatting which enables columns and/or rows to be "banded" by applying different formatting to alternating columns or rows. Typically every other column is formatted the same. So, for example, odd columns may have gray shading and even columns may have green shading. This element can be used to group columns so that alternating groups of columns are formatted the same way rather than every other column. For example, by setting the value of the val attribute to 3, the first three columns will be formatted the same, and the second group of three will be formatted the same, and each group of three thereafter will alternate their formatting. See Table Styles - Conditional Formatting.

<w:style w:type="table" w:styleId="myTableStyle">
<w:tblPr>
<w:tblStyleColBandSize w:val="3"/>
<w:tblStyleRowBandSize w:val="2"/>
</w:tblPr>
</w:style>
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.7.6.5.
tblStyleRowBandSize

This element is applicable to a <tblPr> within a table style. Tables styles can have conditional formatting which enables columns and/or rows to be "banded" by applying different formatting to alternating columns or rows. Typically every other row is formatted the same. So, for example, odd rows may have gray shading and even rows may have green shading. This element can be used to group rows so that alternating groups of rows are formatted the same way rather than every other row. For example, by setting the value of the val attribute to 3, the first three rows will be formatted the same, and the second group of three will be formatted the same, and each group of three thereafter will alternate their formatting. See Table Styles - Conditional Formatting.

<w:style w:type="table" w:styleId="myTableStyle">
<w:tblPr>
<w:tblStyleColBandSize w:val="3"/>
<w:tblStyleRowBandSize w:val="2"/>
</w:tblPr>
</w:style>
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.7.6.7.
tblW See Table Width.
Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.4.64.


Related Open Document Format (ODF) Property:

Table row properties are specified in the <style:table-properties> element.

<style:style style:name="Table1" style:family="table">
<style:table-properties style:width="4.7in" table:align="right" fo:background-color="#e6e6e6" style:shadow="none" fo:keep-with-next="always"/>
</style:style>
Reference: Open Document Format for Office Applications Version 1.2 (May, 2011) § 17.15.

The <style:table-properties> element can have the following attributes:

AttributesDescription
fo:background-color

Specifies a color for the background of the table.

fo:break-after

Specifies a break after the table. Possible values are auto, column, and page.

fo:break-before

Specifies a break before the table. Possible values are auto, column, and page.

fo:keep-with-next

Specifies when the row should be kept with the table. Possible values are auto and always.

fo:margin, fo:margin-bottom, fo:margin-left, fo:margin-right, and fo:margin-top

Specify a margins for the table. Possible values are a non-negative number or a percent.

style:may-break-between pages

Specifies that page break may occur inside the table. Possible values are true and false.

style:page-number

Specifies the page number that should be used for a new page when the table style specifies a master page. Possible values are auto and a positive number.

style:rel-width

Specifies the width of the table relative to the width of the area that the table is in. Possible value is a percent.

style:width

Specifies the fixed width of the table.

style:shadow

Specifies a shadow effect for the table.

style:writing-mode

Specifies how the content should be written. Possible values are lr-tb, rl-tb, tb-rl, tb-lr, lr, rl, tb, and page.

table:align

Specifies the horizontal alignment. Possible values are center, left, margins, and right.

table:border-model

Specifies the border model. Possible values are collapsing (when adjacent cells have different borders, the wider border appears) and separating (borders appear within the cell)

table:display

Specifies whether the table should be displayed. Possible values are true and false.

Note that <style:table-properties> can also contain a <style:background-image> element.