Style Class

Represents a single built-in or user-defined style.
Inheritance Hierarchy

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.2
public class Style

The Style type exposes the following members.

Protected methodStyle
Initializes a new instance of the Style class
Public propertyCode exampleAliases
Gets all aliases of this style. If style has no aliases then empty array of string is returned.
Public propertyCode exampleBaseStyleName
Gets/sets the name of the style this style is based on.
Public propertyCode exampleBuiltIn
True if this style is one of the built-in styles in MS Word.
Public propertyCode exampleDocument
Gets the owner document.
Public propertyCode exampleFont
Gets the character formatting of the style.
Public propertyCode exampleIsHeading
True when the style is one of the built-in Heading styles.
Public propertyCode exampleIsQuickStyle
Specifies whether this style is shown in the Quick Style gallery inside MS Word UI.
Public propertyCode exampleLinkedStyleName
Gets the name of the Style linked to this one. Returns Empty string if no styles are linked.
Public propertyCode exampleList
Gets the list that defines formatting of this list style.
Public propertyCode exampleListFormat
Provides access to the list formatting properties of a paragraph style.
Public propertyCode exampleName
Gets or sets the name of the style.
Public propertyCode exampleNextParagraphStyleName
Gets/sets the name of the style to be applied automatically to a new paragraph inserted after a paragraph formatted with the specified style.
Public propertyCode exampleParagraphFormat
Gets the paragraph formatting of the style.
Public propertyCode exampleStyleIdentifier
Gets the locale independent style identifier for a built-in style.
Public propertyCode exampleStyles
Gets the collection of styles this style belongs to.
Public propertyCode exampleType
Gets the style type (paragraph or character).
Public methodEquals(Object) (Inherited from Object.)
Public methodCode exampleEquals(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.
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodCode exampleRemove
Removes the specified style from the document.
Public methodToString (Inherited from Object.)
Shows how to change the font formatting of all styles in a document.
Document doc = new Document();
foreach (Style style in doc.Styles)
    if (style.Font != null)
        style.Font.Size = 20;
        style.Font.Name = "Arial";
Shows how to create and use a paragraph style with list formatting.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create a paragraph style and specify some formatting for it
Style style = doc.Styles.Add(StyleType.Paragraph, "MyStyle1");
style.Font.Size = 24;
style.Font.Name = "Verdana";
style.ParagraphFormat.SpaceAfter = 12;

// Create a list and make sure the paragraphs that use this style will use this list
style.ListFormat.List = doc.Lists.Add(ListTemplate.BulletDefault);
style.ListFormat.ListLevelNumber = 0;

// Apply the paragraph style to the current paragraph in the document and add some text
builder.ParagraphFormat.Style = style;
builder.Writeln("Hello World: MyStyle1, bulleted.");

// Change to a paragraph style that has no list formatting
builder.ParagraphFormat.Style = doc.Styles["Normal"];
builder.Writeln("Hello World: Normal.");

builder.Document.Save(ArtifactsDir + "Lists.ParagraphStyleBulleted.doc");
See Also