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

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

The Style type exposes the following members.

Protected methodStyle
Initializes a new instance of the Style class
Public propertyAliases
Gets all aliases of this style. If style has no aliases then empty array of string is returned.
Public propertyBaseStyleName
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 propertyDocument
Gets the owner document.
Public propertyCode exampleFont
Gets the character formatting of the style.
Public propertyIsHeading
True when the style is one of the built-in Heading styles.
Public propertyIsQuickStyle
Specifies whether this style is shown in the Quick Style gallery inside MS Word UI.
Public propertyLinkedStyleName
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 propertyNextParagraphStyleName
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 propertyStyles
Gets the collection of styles this style belongs to.
Public propertyType
Gets the style type (paragraph or character).
Public methodEquals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodEquals(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.
Public methodFetchInheritedParaAttr
Reserved for system use. IParaAttrSource.
Public methodFetchParaAttr
Reserved for system use. IParaAttrSource.
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode exampleRemove
Removes the specified style from the document.
Public methodToString
Returns a string that represents the current object.
(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