Style Class

Definition

Style Definition.

This class is available in Office 2007 and above.

When the object is serialized out as xml, it's qualified name is w:style.

[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleName))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Aliases))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.BasedOn))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.NextParagraphStyle))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.LinkedStyle))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.AutoRedefine))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleHidden))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.UIPriority))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.SemiHidden))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.UnhideWhenUsed))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PrimaryStyle))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Locked))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Personal))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PersonalCompose))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PersonalReply))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Rsid))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleParagraphProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleRunProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleTableProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TableStyleConditionalFormattingTableRowProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleTableCellProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TableStyleProperties))]
[DocumentFormat.OpenXml.OfficeAvailability(DocumentFormat.OpenXml.FileFormatVersions.Office2007)]
[DocumentFormat.OpenXml.SchemaAttr(23, "style")]
public class Style : DocumentFormat.OpenXml.OpenXmlCompositeElement
public class Style : DocumentFormat.OpenXml.OpenXmlCompositeElement
[DocumentFormat.OpenXml.SchemaAttr(23, "style")]
public class Style : DocumentFormat.OpenXml.OpenXmlCompositeElement
[DocumentFormat.OpenXml.SchemaAttr("w:style")]
public class Style : DocumentFormat.OpenXml.OpenXmlCompositeElement
[DocumentFormat.OpenXml.SchemaAttr("w:style")]
public class Style : DocumentFormat.OpenXml.TypedOpenXmlCompositeElement
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleName))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Aliases))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.BasedOn))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.NextParagraphStyle))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.LinkedStyle))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.AutoRedefine))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleHidden))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.UIPriority))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.SemiHidden))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.UnhideWhenUsed))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PrimaryStyle))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Locked))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Personal))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PersonalCompose))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PersonalReply))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Rsid))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleParagraphProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleRunProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleTableProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TableStyleConditionalFormattingTableRowProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleTableCellProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TableStyleProperties))]
public class Style : DocumentFormat.OpenXml.OpenXmlCompositeElement
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleName))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Aliases))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.BasedOn))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.NextParagraphStyle))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.LinkedStyle))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.AutoRedefine))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleHidden))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.UIPriority))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.SemiHidden))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.UnhideWhenUsed))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PrimaryStyle))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Locked))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Personal))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PersonalCompose))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PersonalReply))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Rsid))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleParagraphProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleRunProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleTableProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TableStyleConditionalFormattingTableRowProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleTableCellProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TableStyleProperties))]
[DocumentFormat.OpenXml.OfficeAvailability(DocumentFormat.OpenXml.FileFormatVersions.Office2007)]
public class Style : DocumentFormat.OpenXml.OpenXmlCompositeElement
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleName))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Aliases))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.BasedOn))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.NextParagraphStyle))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.LinkedStyle))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.AutoRedefine))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleHidden))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.UIPriority))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.SemiHidden))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.UnhideWhenUsed))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PrimaryStyle))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Locked))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Personal))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PersonalCompose))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PersonalReply))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Rsid))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleParagraphProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleRunProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleTableProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TableStyleConditionalFormattingTableRowProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleTableCellProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TableStyleProperties))>]
[<DocumentFormat.OpenXml.OfficeAvailability(DocumentFormat.OpenXml.FileFormatVersions.Office2007)>]
[<DocumentFormat.OpenXml.SchemaAttr(23, "style")>]
type Style = class
    inherit OpenXmlCompositeElement
type Style = class
    inherit OpenXmlCompositeElement
[<DocumentFormat.OpenXml.SchemaAttr(23, "style")>]
type Style = class
    inherit OpenXmlCompositeElement
[<DocumentFormat.OpenXml.SchemaAttr("w:style")>]
type Style = class
    inherit OpenXmlCompositeElement
[<DocumentFormat.OpenXml.SchemaAttr("w:style")>]
type Style = class
    inherit TypedOpenXmlCompositeElement
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleName))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Aliases))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.BasedOn))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.NextParagraphStyle))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.LinkedStyle))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.AutoRedefine))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleHidden))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.UIPriority))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.SemiHidden))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.UnhideWhenUsed))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PrimaryStyle))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Locked))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Personal))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PersonalCompose))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PersonalReply))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Rsid))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleParagraphProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleRunProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleTableProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TableStyleConditionalFormattingTableRowProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleTableCellProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TableStyleProperties))>]
type Style = class
    inherit OpenXmlCompositeElement
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleName))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Aliases))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.BasedOn))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.NextParagraphStyle))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.LinkedStyle))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.AutoRedefine))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleHidden))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.UIPriority))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.SemiHidden))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.UnhideWhenUsed))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PrimaryStyle))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Locked))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Personal))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PersonalCompose))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PersonalReply))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Rsid))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleParagraphProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleRunProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleTableProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TableStyleConditionalFormattingTableRowProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.StyleTableCellProperties))>]
[<DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TableStyleProperties))>]
[<DocumentFormat.OpenXml.OfficeAvailability(DocumentFormat.OpenXml.FileFormatVersions.Office2007)>]
type Style = class
    inherit OpenXmlCompositeElement
Public Class Style
Inherits OpenXmlCompositeElement
Public Class Style
Inherits TypedOpenXmlCompositeElement
Inheritance
Inheritance
Attributes

Examples

The following code example opens a word processing file that contains some text, and applies the style "Heading 1" to the first paragraph.

using System;  
using System.Linq;  
using DocumentFormat.OpenXml.Packaging;  
using DocumentFormat.OpenXml.Wordprocessing;  

namespace StyleEx  
{  
    class Program  
    {  
        // Apply the Heading 1 style to a paragraph.  
        static void Main(string[] args)  
        {  
            string fileName = @"C:\users\public\documents\StyleEx.docx";  

            using (WordprocessingDocument document =   
                WordprocessingDocument.Open(fileName, true))  
            {  
                // Get the first paragraph.  
                Paragraph p =  
                    document.MainDocumentPart.Document.Body.Elements<Paragraph>().First();  

                // If the paragraph has no ParagraphProperties objects, create a new one for it.  
                if (p.Elements<ParagraphProperties>().Count() == 0)  
                {  
                    p.PrependChild<ParagraphProperties>(new ParagraphProperties());  
                }  

                // Get the paragraph properties element of the paragraph.  
                ParagraphProperties pPr = p.Elements<ParagraphProperties>().First();  

                // Set the paragraph style ID to "Heading1".  
                pPr.ParagraphStyleId = new ParagraphStyleId() { Val = "Heading1" };                
            }  
        }  
    }  
}  
Imports System.Linq  
Imports DocumentFormat.OpenXml.Wordprocessing  
Imports DocumentFormat.OpenXml.Packaging  

Module Module1  
    ' Apply the Heading 1 style to a paragraph.  
    Sub Main()  
        Dim fileName As String = "C:\Users\Public\Documents\StyleEx.docx"  

        Using doc As WordprocessingDocument = _  
            WordprocessingDocument.Open(fileName, True)  
            ' Get the first paragraph.  
            Dim p As Paragraph = doc.MainDocumentPart.Document.Body.Elements _  
                (Of Paragraph).First()  

            ' If the paragraph has no ParagraphProperties objects, create a new one for it.  
            If p.Elements(Of ParagraphProperties).Count() = 0 Then  
                p.PrependChild(Of ParagraphProperties)(New ParagraphProperties())  
            End If  

            ' Get the paragraph properties element of the paragraph.  
            Dim pPr As ParagraphProperties = p.Elements(Of ParagraphProperties).First()  

            ' Set the paragraph style ID to "Heading1".  
            pPr.ParagraphStyleId = New ParagraphStyleId() With {.Val = "Heading1"}  
        End Using  
    End Sub  
End Module  

Remarks

[ISO/IEC 29500-1 1st Edition]

style (Style Definition)

This element specifies the definition of a single style within a WordprocessingML document. A style is a predefined set of table, numbering, paragraph, and/or character properties which can be applied to regions within a document.

The style definition for any style definition can be divided into three segments:

  • General style properties

  • Style type

  • Style type-specific properties

General style properties refers to the set of properties which can be used regardless of the style type; for example, the style name, additional aliases for the style, a style ID (used by the document content to refer to the style), if style is hidden, if style is locked, etc.

[Example: Consider a style called Heading a document as follows:

<w:style w:type="paragraph" w:styleId="Heading1">  
  <w:name w:val="Heading 1"/>  
  <w:basedOn w:val="Normal"/>  
  <w:next w:val="Normal"/>  
  <w:link w:val="Heading1Char"/>  
  <w:uiPriority w:val="1"/>  
  <w:qformat/>  
  <w:rsid w:val="00F303CE"/>  
  …</w:style>  

Above the formatting information specific to this style type are a set of general style properties which define information shared by all style types. end example]

Style types refers to the property on a style which defines the type of style created with this style definition. WordprocessingML supports six types of style definitions by the values for the style definition's type attribute:

  • Paragraph styles

  • Character styles

  • Linked styles (paragraph + character) [Note: Accomplished via the link element (§17.7.4.6). end note]

  • Table styles

  • Numbering styles

  • Default paragraph + character properties

[Example: Consider a style called Heading a document as follows:

<w:style w:type="paragraph" w:styleId="Heading1">  
  <w:name w:val="heading 1"/>  
  <w:basedOn w:val="Normal"/>  
  <w:next w:val="Normal"/>  
  <w:link w:val="Heading1Char"/>  
  <w:uiPriority w:val="1"/>  
  <w:qformat/>  
  <w:rsid w:val="00F303CE"/>  
  …</w:style>  

The type attribute has a value of paragraph, which indicates that the following style definition is a paragraph style. end example]

Style type-specific properties refers to the payload of the style: its formatting information as well as any properties which apply only to that style type.

[Example: Consider a table style with primary name Normal Table defined as follows:

<w:style w:type="table" w:default="1" w:styleId="TableNormal">  
  <w:name w:val="Normal Table"/>  
  …  <w:tblPr>  
    <w:tblInd w:w="0" w:type="dxa"/>  
    <w:tblCellMar>  
      <w:top w:w="0" w:type="dxa"/>  
      <w:left w:w="108" w:type="dxa"/>  
      <w:bottom w:w="0" w:type="dxa"/>  
      <w:right w:w="108" w:type="dxa"/>  
    </w:tblCellMar>  
  </w:tblPr>  
</w:style>  

The tblPr element contains the formatting payload for this table style, which is only applicable to a table style. end example]

Parent Elements
styles (§17.7.4.18)
Child Elements Subclause
aliases (Alternate Style Names) §17.7.4.1
autoRedefine (Automatically Merge User Formatting Into Style Definition) §17.7.4.2
basedOn (Parent Style ID) §17.7.4.3
hidden (Hide Style From User Interface) §17.7.4.4
link (Linked Style Reference) §17.7.4.6
locked (Style Cannot Be Applied) §17.7.4.7
name (Primary Style Name) §17.7.4.9
next (Style For Next Paragraph) §17.7.4.10
personal (E-Mail Message Text Style) §17.7.4.11
personalCompose (E-Mail Message Composition Style) §17.7.4.12
personalReply (E-Mail Message Reply Style) §17.7.4.13
pPr (Style Paragraph Properties) §17.7.8.2
qFormat (Primary Style) §17.7.4.14
rPr (Run Properties) §17.7.9.1
rsid (Revision Identifier for Style Definition) §17.7.4.15
semiHidden (Hide Style From Main User Interface) §17.7.4.16
tblPr (Style Table Properties) §17.7.6.4
tblStylePr (Style Conditional Table Formatting Properties) §17.7.6.6
tcPr (Style Table Cell Properties) §17.7.6.9
trPr (Style Table Row Properties) §17.7.6.11
uiPriority (Optional User Interface Sorting Order) §17.7.4.19
unhideWhenUsed (Remove Semi-Hidden Property When Style Is Used) §17.7.4.20

[Note: The W3C XML Schema definition of this element’s content model (CT_Style) is located in §A.1. end note]

� ISO/IEC29500: 2008.

Constructors

Style()

Initializes a new instance of the Style class.

Style(IEnumerable<OpenXmlElement>)

Initializes a new instance of the Style class with the specified child elements.

Style(OpenXmlElement[])

Initializes a new instance of the Style class with the specified child elements.

Style(String)

Initializes a new instance of the Style class from outer XML.

Properties

Aliases

Alternate Style Names.

Represents the following element tag in the schema: w:aliases.

AutoRedefine

Automatically Merge User Formatting Into Style Definition.

Represents the following element tag in the schema: w:autoRedefine.

BasedOn

Parent Style ID.

Represents the following element tag in the schema: w:basedOn.

ChildElements

Gets all the child nodes of the current element.

(Inherited from OpenXmlElement)
CustomStyle

User-Defined Style

Represents the following attribute in the schema: w:customStyle

Default

Default Style

Represents the following attribute in the schema: w:default

ExtendedAttributes

Gets all extended attributes (attributes not defined in the schema) of the current element.

(Inherited from OpenXmlElement)
Features

Gets a IFeatureCollection for the current element. This feature collection will be read-only, but will inherit features from its parent part and package if available.

(Inherited from OpenXmlElement)
FirstChild

Gets the first child of the current OpenXmlElement element.

(Inherited from OpenXmlCompositeElement)
HasAttributes

Gets a value indicating whether the current element has any attributes.

(Inherited from OpenXmlElement)
HasChildren

Gets a value that indicates whether the current element has any child elements.

(Inherited from OpenXmlCompositeElement)
InnerText

Gets or sets the concatenated values of the current node and all of its children.

(Inherited from OpenXmlCompositeElement)
InnerXml

Gets or sets the markup that represents only the child nodes of the current node.

(Inherited from OpenXmlCompositeElement)
LastChild

Gets the last child of the current OpenXmlElement element. Returns null (Nothing in Visual Basic) if there is no such OpenXmlElement element.

(Inherited from OpenXmlCompositeElement)
LinkedStyle

Linked Style Reference.

Represents the following element tag in the schema: w:link.

LocalName
LocalName

Gets the local name of the current element.

(Inherited from OpenXmlElement)
Locked

Style Cannot Be Applied.

Represents the following element tag in the schema: w:locked.

MCAttributes

Gets or sets the markup compatibility attributes. Returns null if no markup compatibility attributes are defined for the current element.

(Inherited from OpenXmlElement)
NamespaceDeclarations

Gets all the namespace declarations defined in the current element. Returns an empty enumerator if there is no namespace declaration.

(Inherited from OpenXmlElement)
NamespaceUri

Gets the namespace URI of the current element.

(Inherited from OpenXmlElement)
NextParagraphStyle

Style For Next Paragraph.

Represents the following element tag in the schema: w:next.

OpenXmlElementContext

Gets the OpenXmlElementContext of the current element.

(Inherited from OpenXmlElement)
OuterXml

Gets the markup that represents the current element and all of its child elements.

(Inherited from OpenXmlElement)
Parent

Gets the parent element of the current element.

(Inherited from OpenXmlElement)
Personal

E-Mail Message Text Style.

Represents the following element tag in the schema: w:personal.

PersonalCompose

E-Mail Message Composition Style.

Represents the following element tag in the schema: w:personalCompose.

PersonalReply

E-Mail Message Reply Style.

Represents the following element tag in the schema: w:personalReply.

Prefix

Gets the namespace prefix of current element.

(Inherited from OpenXmlElement)
PrimaryStyle

Primary Style.

Represents the following element tag in the schema: w:qFormat.

Rsid

Revision Identifier for Style Definition.

Represents the following element tag in the schema: w:rsid.

SemiHidden

Hide Style From Main User Interface.

Represents the following element tag in the schema: w:semiHidden.

StyleHidden

Hide Style From User Interface.

Represents the following element tag in the schema: w:hidden.

StyleId

Style ID

Represents the following attribute in the schema: w:styleId

StyleName

Primary Style Name.

Represents the following element tag in the schema: w:name.

StyleParagraphProperties

Style Paragraph Properties.

Represents the following element tag in the schema: w:pPr.

StyleRunProperties

Run Properties.

Represents the following element tag in the schema: w:rPr.

StyleTableCellProperties

Style Table Cell Properties.

Represents the following element tag in the schema: w:tcPr.

StyleTableProperties

Style Table Properties.

Represents the following element tag in the schema: w:tblPr.

TableStyleConditionalFormattingTableRowProperties

Style Table Row Properties.

Represents the following element tag in the schema: w:trPr.

Type

Style Type

Represents the following attribute in the schema: w:type

UIPriority

Optional User Interface Sorting Order.

Represents the following element tag in the schema: w:uiPriority.

UnhideWhenUsed

Remove Semi-Hidden Property When Style Is Used.

Represents the following element tag in the schema: w:unhideWhenUsed.

XmlQualifiedName

Gets the qualified name of the current element.

(Inherited from OpenXmlElement)
XName

Gets the qualified name of the current element.

(Inherited from OpenXmlElement)

Methods

AddAnnotation(Object)

Adds an object to the current OpenXmlElement element's list of annotations.

(Inherited from OpenXmlElement)
AddChild(OpenXmlElement, Boolean)

Adds the specified element to the element if it is a known child. This adds the element in the correct location according to the schema.

(Inherited from OpenXmlCompositeElement)
AddNamespaceDeclaration(String, String)

Adds a namespace declaration to the current node.

(Inherited from OpenXmlElement)
Ancestors()

Enumerates all of the current element's ancestors.

(Inherited from OpenXmlElement)
Ancestors<T>()

Enumerates only the current element's ancestors that have the specified type.

(Inherited from OpenXmlElement)
Annotation(Type)

Get the first annotation object of the specified type from the current OpenXmlElement element.

(Inherited from OpenXmlElement)
Annotation<T>()

Get the first annotation object of the specified type from the current OpenXmlElement element.

(Inherited from OpenXmlElement)
Annotations(Type)

Gets a collection of annotations with the specified type for the current OpenXmlElement element.

(Inherited from OpenXmlElement)
Annotations<T>()

Gets a collection of annotations with the specified type for the current OpenXmlElement element.

(Inherited from OpenXmlElement)
Append(IEnumerable<OpenXmlElement>)

Appends each element from a list of elements to the end of the current element's list of child elements.

(Inherited from OpenXmlElement)
Append(OpenXmlElement[])

Appends each element from an array of elements to the end of the current element's list of child elements.

(Inherited from OpenXmlElement)
AppendChild<T>(T)

Appends the specified element to the end of the current element's list of child nodes.

(Inherited from OpenXmlCompositeElement)
ClearAllAttributes()

Clears all of the attributes, including both known attributes and extended attributes.

(Inherited from OpenXmlElement)
Clone()

Creates a duplicate of the current node.

(Inherited from OpenXmlElement)
CloneNode(Boolean)

Creates a duplicate of this node.

Descendants()

Enumerates all of the current element's descendants.

(Inherited from OpenXmlElement)
Descendants<T>()

Enumerate all of the current element's descendants of type T.

(Inherited from OpenXmlElement)
Elements()

Enumerates all of the current element's children.

(Inherited from OpenXmlElement)
Elements<T>()

Enumerates only the current element's children that have the specified type.

(Inherited from OpenXmlElement)
ElementsAfter()

Enumerates all of the sibling elements that follow the current element and have the same parent as the current element.

(Inherited from OpenXmlElement)
ElementsBefore()

Enumerates all of the sibling elements that precede the current element and have the same parent as the current element.

(Inherited from OpenXmlElement)
GetAttribute(String, String)

Gets an Open XML attribute with the specified tag name and namespace URI.

(Inherited from OpenXmlElement)
GetAttributes()

Gets a list that contains a copy of all the attributes.

(Inherited from OpenXmlElement)
GetEnumerator()

Returns an enumerator that iterates through the child collection.

(Inherited from OpenXmlElement)
GetFirstChild<T>()

Finds the first child element in type T.

(Inherited from OpenXmlElement)
InsertAfter<T>(T, OpenXmlElement)

Inserts the specified element immediately after the specified reference element.

(Inherited from OpenXmlCompositeElement)
InsertAfterSelf<T>(T)

Inserts the specified element immediately after the current element.

(Inherited from OpenXmlElement)
InsertAt<T>(T, Int32)

Inserts the specified element at the specified index of the current element's children.

(Inherited from OpenXmlCompositeElement)
InsertBefore<T>(T, OpenXmlElement)

Inserts the specified element immediately before the specified reference element.

(Inherited from OpenXmlCompositeElement)
InsertBeforeSelf<T>(T)

Inserts the specified element immediately before the current element.

(Inherited from OpenXmlElement)
IsAfter(OpenXmlElement)

Determines if the current element appears after a specified element in document order.

(Inherited from OpenXmlElement)
IsBefore(OpenXmlElement)

Determines if the current element appears before a specified element in document order.

(Inherited from OpenXmlElement)
LookupNamespace(String)

Resolves the namespace prefix in the context of the current node.

(Inherited from OpenXmlElement)
LookupPrefix(String)

Finds the corresponding prefix for a namespace uri in the current element scope.

(Inherited from OpenXmlElement)
NextSibling()

Gets the OpenXmlElement element that immediately follows the current OpenXmlElement element. Returns null (Nothing in Visual Basic) if there is no next OpenXmlElement element.

(Inherited from OpenXmlElement)
NextSibling<T>()

Gets the OpenXmlElement element with the specified type that follows the current OpenXmlElement element. Returns null (Nothing in Visual Basic) if there is no next OpenXmlElement.

(Inherited from OpenXmlElement)
PrependChild<T>(T)

Inserts the specified element at the beginning of the current element's list of child nodes.

(Inherited from OpenXmlCompositeElement)
PreviousSibling()

Gets the OpenXmlElement element that immediately precedes the current OpenXmlElement element. Returns null (Nothing in Visual Basic ) if there is no preceding OpenXmlElement element.

(Inherited from OpenXmlElement)
PreviousSibling<T>()

Gets the OpenXmlElement element with the specified type that precedes the current OpenXmlElement. Returns null (Nothing in Visual Basic) if there is no preceding OpenXmlElement element.

(Inherited from OpenXmlElement)
Remove()

Removes the current element from its parent.

(Inherited from OpenXmlElement)
RemoveAllChildren()

Removes all of the current element's child elements.

(Inherited from OpenXmlCompositeElement)
RemoveAllChildren<T>()

Remove all of the current element's child elements that are of type T.

(Inherited from OpenXmlElement)
RemoveAnnotations(Type)

Removes the annotations of the specified type from the current OpenXmlElement element.

(Inherited from OpenXmlElement)
RemoveAnnotations<T>()

Removes the annotations with the specified type from the current OpenXmlElement element.

(Inherited from OpenXmlElement)
RemoveAttribute(String, String)

Removes the attribute from the current element.

(Inherited from OpenXmlElement)
RemoveChild<T>(T)

Removes the specified child element.

(Inherited from OpenXmlCompositeElement)
RemoveNamespaceDeclaration(String)

Removes the namespace declaration for the specified prefix. Removes nothing if there is no prefix.

(Inherited from OpenXmlElement)
ReplaceChild<T>(OpenXmlElement, T)

Replaces one of the current element's child elements with another OpenXmlElement element.

(Inherited from OpenXmlCompositeElement)
SetAttribute(OpenXmlAttribute)

Sets an attribute to the specified element. If the attribute is a known attribute, the value of the attribute is set. If the attribute is an extended attribute, the 'openxmlAttribute' is added to the extended attributes list.

(Inherited from OpenXmlElement)
SetAttributes(IEnumerable<OpenXmlAttribute>)

Sets a number of attributes to the element. If an attribute is a known attribute, the value of the attribute is set. If an attribute is an extended attribute, the 'openxmlAttribute' is added to the extended attributes list.

(Inherited from OpenXmlElement)
WriteTo(XmlWriter)

Saves the current node to the specified XmlWriter.

(Inherited from OpenXmlElement)

Explicit Interface Implementations

IEnumerable.GetEnumerator() (Inherited from OpenXmlElement)
IEnumerable<OpenXmlElement>.GetEnumerator()

Returns an enumerator that iterates through the child collection.

(Inherited from OpenXmlElement)

Applies to