TableStyle class

TableStyle class

Represents a table style. To learn more, visit the Working with Tables documentation article.

Inheritance: TableStyleStyle

Properties

NameDescription
aliasesGets all aliases of this style. If style has no aliases then empty array of string is returned.
(Inherited from Style)
alignmentSpecifies the alignment for the table style.
allow_break_across_pagesGets or sets a flag indicating whether text in a table row is allowed to split across a page break.
automatically_updateSpecifies whether this style is automatically redefined based on the appropriate value.
(Inherited from Style)
base_style_nameGets/sets the name of the style this style is based on.
(Inherited from Style)
bidiGets or sets whether this is a style for a right-to-left table.
bordersGets the collection of default cell borders for the style.
bottom_paddingGets or sets the amount of space (in points) to add below the contents of table cells.
built_inTrue if this style is one of the built-in styles in MS Word.
(Inherited from Style)
cell_spacingGets or sets the amount of space (in points) between the cells.
column_stripeGets or sets a number of columns to include in the banding when the style specifies odd/even columns banding.
conditional_stylesCollection of conditional styles that may be defined for this table style.
documentGets the owner document.
(Inherited from Style)
fontGets the character formatting of the style.
(Inherited from Style)
is_headingTrue when the style is one of the built-in Heading styles.
(Inherited from Style)
is_quick_styleSpecifies whether this style is shown in the Quick Style gallery inside MS Word UI.
(Inherited from Style)
left_indentGets or sets the value that represents the left indent of a table.
left_paddingGets or sets the amount of space (in points) to add to the left of the contents of table cells.
linked_style_nameGets/sets the name of the Style linked to this one. Returns empty string if no styles are linked.
(Inherited from Style)
listGets the list that defines formatting of this list style.
(Inherited from Style)
list_formatProvides access to the list formatting properties of a paragraph style.
(Inherited from Style)
lockedSpecifies whether this style is locked.
(Inherited from Style)
nameGets or sets the name of the style.
(Inherited from Style)
next_paragraph_style_nameGets/sets the name of the style to be applied automatically to a new paragraph inserted after a paragraph formatted with the specified style.
(Inherited from Style)
paragraph_formatGets the paragraph formatting of the style.
(Inherited from Style)
priorityGets/sets the integer value that represents the priority for sorting the styles in the Styles task pane.
(Inherited from Style)
right_paddingGets or sets the amount of space (in points) to add to the right of the contents of table cells.
row_stripeGets or sets a number of rows to include in the banding when the style specifies odd/even row banding.
semi_hiddenGets/sets whether the style hides from the Styles gallery and from the Styles task pane.
(Inherited from Style)
shadingGets a Shading object that refers to the shading formatting for table cells.
style_identifierGets the locale independent style identifier for a built-in style.
(Inherited from Style)
stylesGets the collection of styles this style belongs to.
(Inherited from Style)
top_paddingGets or sets the amount of space (in points) to add above the contents of table cells.
typeGets the style type (paragraph or character).
(Inherited from Style)
unhide_when_usedGets/sets whether the style used in the current document unhides from the Styles gallery and from the Styles task pane. True when the used style should be shown in the Styles gallery.
(Inherited from Style)
vertical_alignmentSpecifies the vertical alignment for the cells.

Methods

NameDescription
equals(style)Compares with the specified style. Styles Istds are compared for built-in styles only. Styles defaults are not included in comparison. Base style, linked style and next paragraph style are recursively compared.
(Inherited from Style)
remove()Removes the specified style from the document.
(Inherited from Style)

Examples

Shows how to create custom style settings for the table.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
table = builder.start_table()
builder.insert_cell()
builder.write('Name')
builder.insert_cell()
builder.write('مرحبًا')
builder.end_row()
builder.insert_cell()
builder.insert_cell()
builder.end_table()
table_style = doc.styles.add(aw.StyleType.TABLE, 'MyTableStyle1').as_table_style()
table_style.allow_break_across_pages = True
table_style.bidi = True
table_style.cell_spacing = 5
table_style.bottom_padding = 20
table_style.left_padding = 5
table_style.right_padding = 10
table_style.top_padding = 20
table_style.shading.background_pattern_color = aspose.pydrawing.Color.antique_white
table_style.borders.color = aspose.pydrawing.Color.blue
table_style.borders.line_style = aw.LineStyle.DOT_DASH
table_style.vertical_alignment = aw.tables.CellVerticalAlignment.CENTER
table.style = table_style
# Setting the style properties of a table may affect the properties of the table itself.
self.assertTrue(table.bidi)
self.assertEqual(5.0, table.cell_spacing)
self.assertEqual('MyTableStyle1', table.style_name)
doc.save(ARTIFACTS_DIR + 'Table.table_style_creation.docx')

See Also