Style class

Style class

Represents a single built-in or user-defined style. To learn more, visit the Working with Styles and Themes documentation article.


aliasesGets all aliases of this style. If style has no aliases then empty array of string is returned.
automatically_updateSpecifies whether this style is automatically redefined based on the appropriate value.
base_style_nameGets/sets the name of the style this style is based on.
built_inTrue if this style is one of the built-in styles in MS Word.
documentGets the owner document.
fontGets the character formatting of the style.
is_headingTrue when the style is one of the built-in Heading styles.
is_quick_styleSpecifies whether this style is shown in the Quick Style gallery inside MS Word UI.
linked_style_nameGets/sets the name of the Style linked to this one. Returns empty string if no styles are linked.
listGets the list that defines formatting of this list style.
list_formatProvides access to the list formatting properties of a paragraph style.
lockedSpecifies whether this style is locked.
nameGets or sets the name of the 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.
paragraph_formatGets the paragraph formatting of the style.
priorityGets/sets the integer value that represents the priority for sorting the styles in the Styles task pane.
semi_hiddenGets/sets whether the style hides from the Styles gallery and from the Styles task pane.
style_identifierGets the locale independent style identifier for a built-in style.
stylesGets the collection of styles this style belongs to.
typeGets the style type (paragraph or character).
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.


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.
remove()Removes the specified style from the document.


Shows how to create and use a paragraph style with list formatting.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
# Create a custom paragraph style.
style = doc.styles.add(aw.StyleType.PARAGRAPH, 'MyStyle1')
style.font.size = 24 = 'Verdana'
style.paragraph_format.space_after = 12
# Create a list and make sure the paragraphs that use this style will use this list.
style.list_format.list = doc.lists.add(list_template=aw.lists.ListTemplate.BULLET_DEFAULT)
style.list_format.list_level_number = 0
# Apply the paragraph style to the document builder's current paragraph, and then add some text. = style
builder.writeln('Hello World: MyStyle1, bulleted list.')
# Change the document builder's style to one that has no list formatting and write another paragraph. = doc.styles.get_by_name('Normal')
builder.writeln('Hello World: Normal.') + 'Styles.ParagraphStyleBulletedList.docx')

Shows how to create and apply a custom style.

doc = aw.Document()
style = doc.styles.add(aw.StyleType.PARAGRAPH, 'MyStyle') = 'Times New Roman'
style.font.size = 16
style.font.color =
# Automatically redefine style.
style.automatically_update = True
builder = aw.DocumentBuilder(doc)
# Apply one of the styles from the document to the paragraph that the document builder is creating. = doc.styles.get_by_name('MyStyle')
builder.writeln('Hello world!')
first_paragraph_style =
self.assertEqual(style, first_paragraph_style)
# Remove our custom style from the document's styles collection.
first_paragraph_style =
# Any text that used a removed style reverts to the default formatting.
self.assertFalse(any(( == 'MyStyle' for s in doc.styles)))
self.assertEqual('Times New Roman',
self.assertEqual(12.0, first_paragraph_style.font.size)
self.assertEqual(aspose.pydrawing.Color.empty().to_argb(), first_paragraph_style.font.color.to_argb())

See Also