Wordprocessing Styles
Table styles can define conditional formatting which is applied to different regions of the table. Conditional formatting is specified by the <w:tblStylePr> element within the <w:style> element. The regions that can have conditional formatting are shown below.
Top left cell | Header row | Top right cell |
First column | Table body | Last column |
Bottom left cell | Footer row | Bottom right cell |
In addition to the regions above, rows within a table can also have conditional formatting on an alternating row/column basis to achive a banded effect. For example, the sample below has banded rows and columns, with the odd rows and columns having formatting applied.
The actual application of each of these sets of conditional formatting in a given table that references the table style is determined by the attributes of the tblLook element within the tblPr of the table. In this way the properties are "conditional." See Tables - Conditional Formatting. Below is the definition of a table style within the styles part that defines non-conditional formatting, as well as conditional formatting for the first row that consists of bolding and red shading for table cells and spacing formatting for the last row.
Note: There may be multiple instances of <w:tblStylePr> within a table style definition - one for each conditionally formatted region.
The above table style is then applied in content as shown below. Note in particular the <w:tblLook> element. The bold and shade formatting for the first row is applied because the <w:tblLook> element contains a value of true for its firstRow attribute. The conditional formatting for the last row is not applied.
Note that when multiple conditional formatting sets are applied, there may be conflicts between them. The conditional formats are applied in the following order:
- Whole table
- Banded columns, even column banding
- Banded rows, even row banding
- First row, last row
- First column, last column
- Top left, top right, bottom left, bottom right
Attributes of <w:tblStylePr>
There is only one attribute, type, which determines the region to which the conditional formatting applies.
Attribute | Description |
---|---|
type | The following possible values are:
|
Child Elements of <w:tblStylePr>:
Element | Description |
---|---|
pPr | Specifies the set of paragraph properties to be applied to paragraphs in a table which match the conditional formatting type. For the details, see Paragraphs - Properties. Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.7.6.1.
|
rPr | Specifies the set of run properties to be applied to runs in a table which match the conditional formatting type. For the details, see Text - Formatting. Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.7.6.2.
|
tblPr | Specifies the set of table properties to be applied to all regions of a table which match the conditional formatting type. For the details, see Tables - Properties. If the conditional formatting does not consist of one or more full table rows, then table properties which can't be applied to a single cell or column are ignored. Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.7.6.3.
|
tcPr | Specifies the set of table cell properties to be applied to cells in a table which match the conditional formatting type. For the details, see Tables - Cell Properties. Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.7.6.8.
|
trPr | Specifies the set of table row properties to be applied to rows in a table which match the conditional formatting type. For the details, see Tables - Row Properties. Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.7.6.10.
|
Related HTML/CSS property:
- This is the first level.
- This is the second level.
- This is the third level.