StyleName Property

Gets or sets the name of the style.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public string Name { get; set; }

Property Value

Type: String
Remarks

Can not be empty string.

If there already is a style with such name in the collection, then this style will override it. All affected nodes will reference new style.

Examples
Demonstrates how to copy a style within the same document.
// The AddCopy method creates a copy of the specified style and automatically generates a new name for the style, such as "Heading 1_0"
Style newStyle = doc.Styles.AddCopy(doc.Styles["Heading 1"]);

// You can change the new style name if required as the Style.Name property is read-write
newStyle.Name = "My Heading 1";
Examples
Shows how to get access to the collection of styles defined in the document.
Document doc = new Document();

using (IEnumerator<Style> stylesEnum = doc.Styles.GetEnumerator())
{
    while (stylesEnum.MoveNext())
    {
        Style curStyle = stylesEnum.Current;
        Console.WriteLine($"Style name:\t\"{curStyle.Name}\", of type \"{curStyle.Type}\"");
        Console.WriteLine($"\tSubsequent style:\t{curStyle.NextParagraphStyleName}");
        Console.WriteLine($"\tIs heading:\t\t\t{curStyle.IsHeading}");
        Console.WriteLine($"\tIs QuickStyle:\t\t{curStyle.IsQuickStyle}");

        Assert.AreEqual(doc, curStyle.Document);
    }
}
See Also