StyleCollectionItem Property (StyleIdentifier) |
Namespace: Aspose.Words
When accessing a style that does not yet exist, automatically creates it.
Document doc = new Document(); // New documents come with a collection of default styles that can be applied to paragraphs StyleCollection styles = doc.Styles; Assert.AreEqual(4, styles.Count); // We can set default parameters for new styles that will be added to the collection from now on styles.DefaultFont.Name = "Courier New"; styles.DefaultParagraphFormat.FirstLineIndent = 15.0; styles.Add(StyleType.Paragraph, "MyStyle"); // Styles within the collection can be referenced either by index or name Assert.AreEqual("Courier New", styles[4].Font.Name); Assert.AreEqual(15.0, styles["MyStyle"].ParagraphFormat.FirstLineIndent);