Style 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
样式定义。
此类在 Office 2007 及更高版本中可用。
将对象序列化为 xml 时,其限定名称为 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.OpenXmlCompositeElementpublic 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 OpenXmlCompositeElementtype 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 OpenXmlCompositeElementPublic Class Style
Inherits OpenXmlCompositeElementPublic Class Style
Inherits TypedOpenXmlCompositeElement- 继承
- 继承
- 属性
示例
下面的代码示例打开包含一些文本的字处理文件,并将样式“标题 1”应用于第一个段落。
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  
注解
[ISO/IEC 29500-1 第 1 版]
样式 (样式定义)
此元素指定 WordprocessingML 文档中单个样式的定义。 样式是一组预定义的表格、编号、段落和/或字符属性,可应用于文档中的区域。
任何样式定义的样式定义可分为三个部分:
- 常规样式属性 
- 样式类型 
- 样式类型特定的属性 
常规样式属性 是指无论样式类型如何,都可以使用的属性集;例如,样式名称、样式的其他别名、文档内容 (用来引用样式) 样式的样式 ID、如果隐藏样式、如果样式已锁定等。
[示例: 请考虑名为文档标题的样式,如下所示:
<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>  
特定于此样式类型的格式设置信息上方是一组常规样式属性,用于定义由所有样式类型共享的信息。 示例结束]
样式类型 指的是样式上的属性,用于定义使用此样式定义创建的样式的类型。 根据样式定义的类型属性的值,WordprocessingML 支持六种样式定义类型:
- 段落样式 
- 字符样式 
- 链接样式(段落 + 字符)[注释:通过链接元素实现 (§17.7.4.6)。 注释结束] 
- 表样式 
- 编号样式 
- 默认段落 + 字符属性 
[示例: 请考虑名为文档标题的样式,如下所示:
<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>  
类型属性具有 段落值,指示以下样式定义是段落样式。 示例结束]
样式类型特定的属性 是指样式的有效负载:其格式信息以及仅适用于该样式类型的任何属性。
[示例:请考虑主名称 为 Normal Table 的表样式,定义如下:
<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>  
tblPr 元素包含此表格样式的格式有效负载,该格式仅适用于表格样式。 示例结束]
| 父元素 | 
|---|
| styles (§17.7.4.18) | 
| 子元素 | 第 | 
|---|---|
| 别名 (备用样式名称) | §17.7.4.1 | 
| autoRedefine (自动将用户格式合并到样式定义) | §17.7.4.2 | 
| basedOn (父样式 ID) | §17.7.4.3 | 
| 隐藏 (用户界面) 隐藏样式 | §17.7.4.4 | 
| 链接 (链接样式参考) | §17.7.4.6 | 
| 无法应用锁定 (样式) | §17.7.4.7 | 
| 名称 (主要样式名称) | §17.7.4.9 | 
| 下一 (段) 的下一个 (样式 | §17.7.4.10 | 
| 个人 (电子邮件文本样式) | §17.7.4.11 | 
| personalCompose (电子邮件撰写样式) | §17.7.4.12 | 
| personalReply (电子邮件回复样式) | §17.7.4.13 | 
| pPr (样式段落属性) | §17.7.8.2 | 
| qFormat (主要样式) | §17.7.4.14 | 
| rPr (运行属性) | §17.7.9.1 | 
| 样式定义) 的 rsid (修订标识符 | §17.7.4.15 | 
| semiHidden (在主用户界面) 隐藏样式 | §17.7.4.16 | 
| tblPr (样式表属性) | §17.7.6.4 | 
| tblStylePr (样式条件表格式设置属性) | §17.7.6.6 | 
| tcPr (样式表单元格属性) | §17.7.6.9 | 
| trPr (样式表行属性) | §17.7.6.11 | 
| uiPriority (可选用户界面排序顺序) | §17.7.4.19 | 
| unhideWhenUsed (使用样式时删除 Semi-Hidden 属性) | §17.7.4.20 | 
[注意:此元素的内容模型 (CT_Style) 的 W3C XML 架构定义位于 §A.1 中。 注释结束]
ISO/IEC29500:2008。
构造函数
| Style() | 初始化 Style 类的新实例。 | 
| Style(IEnumerable<OpenXmlElement>) | 使用指定的子元素初始化 Style 类的新实例。 | 
| Style(OpenXmlElement[]) | 使用指定的子元素初始化 Style 类的新实例。 | 
| Style(String) | 从外部 XML 初始化 Style 类的新实例。 | 
属性
| Aliases | 备用样式名称。 表示架构中的以下元素标记:w:aliases。 | 
| AutoRedefine | 自动将用户格式合并到样式定义中。 表示架构中的以下元素标记:w:autoRedefine。 | 
| BasedOn | 父样式 ID。 表示架构中的以下元素标记:w:basedOn。 | 
| ChildElements | 获取当前元素的所有子节点。(继承自 OpenXmlElement) | 
| CustomStyle | User-Defined 样式 表示架构中的以下属性:w:customStyle | 
| Default | 默认样式 表示架构中的以下属性:w:default | 
| ExtendedAttributes | 获取当前元素的架构) 中未定义的所有扩展属性 (属性。(继承自 OpenXmlElement) | 
| Features | IFeatureCollection获取当前元素的 。 此功能集合将是只读的,但会从其父部件和包继承功能(如果可用)。(继承自 OpenXmlElement) | 
| FirstChild | 获取当前 OpenXmlElement 元素的第一个子元素。(继承自 OpenXmlCompositeElement) | 
| HasAttributes | 获取一个值,该值指示当前元素是否具有任何属性。(继承自 OpenXmlElement) | 
| HasChildren | 获取一个值,该值指示当前元素是否具有任何子元素。(继承自 OpenXmlCompositeElement) | 
| InnerText | 获取或设置当前节点及其所有子节点的串联值。(继承自 OpenXmlCompositeElement) | 
| InnerXml | 获取或设置仅表示当前节点的子节点的标记。(继承自 OpenXmlCompositeElement) | 
| LastChild | 获取当前 OpenXmlElement 元素的最后一个子元素。 如果没有这样的 OpenXmlElement 元素,则返回 null (Visual Basic) Nothing。(继承自 OpenXmlCompositeElement) | 
| LinkedStyle | 链接样式引用。 表示架构中的以下元素标记:w:link。 | 
| LocalName | 样式定义。 此类在 Office 2007 及更高版本中可用。 将对象序列化为 xml 时,其限定名称为 w:style。 | 
| LocalName | 获取当前元素的本地名称。(继承自 OpenXmlElement) | 
| Locked | 无法应用样式。 表示架构中的以下元素标记:w:locked。 | 
| MCAttributes | 获取或设置标记兼容性属性。 如果未为当前元素定义标记兼容性属性,则返回 null。(继承自 OpenXmlElement) | 
| NamespaceDeclarations | 获取在当前元素中定义的所有命名空间声明。 如果没有命名空间声明,则返回空枚举器。(继承自 OpenXmlElement) | 
| NamespaceUri | 获取当前元素的命名空间 URI。(继承自 OpenXmlElement) | 
| NextParagraphStyle | 下一段落的样式。 表示架构中的以下元素标记:w:next。 | 
| OpenXmlElementContext | 获取当前元素的 OpenXmlElementContext。(继承自 OpenXmlElement) | 
| OuterXml | 获取表示当前元素及其所有子元素的标记。(继承自 OpenXmlElement) | 
| Parent | 获取当前元素的父元素。(继承自 OpenXmlElement) | 
| Personal | 电子邮件文本样式。 表示架构中的以下元素标记:w:personal。 | 
| PersonalCompose | 电子邮件撰写样式。 表示架构中的以下元素标记:w:personalCompose。 | 
| PersonalReply | 电子邮件答复样式。 表示架构中的以下元素标记:w:personalReply。 | 
| Prefix | 获取当前元素的命名空间前缀。(继承自 OpenXmlElement) | 
| PrimaryStyle | 主要样式。 表示架构中的以下元素标记:w:qFormat。 | 
| Rsid | 样式定义的修订标识符。 表示架构中的以下元素标记:w:rsid。 | 
| SemiHidden | 在主用户界面中隐藏样式。 表示架构中的以下元素标记:w:semiHidden。 | 
| StyleHidden | 在用户界面中隐藏样式。 表示架构中的以下元素标记:w:hidden。 | 
| StyleId | 样式 ID 表示架构中的以下属性:w:styleId | 
| StyleName | 主要样式名称。 表示架构中的以下元素标记:w:name。 | 
| StyleParagraphProperties | 样式段落属性。 表示架构中的以下元素标记:w:pPr。 | 
| StyleRunProperties | 运行属性。 表示架构中的以下元素标记:w:rPr。 | 
| StyleTableCellProperties | 样式表单元格属性。 表示架构中的以下元素标记:w:tcPr。 | 
| StyleTableProperties | 样式表属性。 表示架构中的以下元素标记:w:tblPr。 | 
| TableStyleConditionalFormattingTableRowProperties | 样式表行属性。 表示架构中的以下元素标记:w:trPr。 | 
| Type | 样式类型 表示架构中的以下属性:w:type | 
| UIPriority | 可选用户界面排序顺序。 表示架构中的以下元素标记:w:uiPriority。 | 
| UnhideWhenUsed | 使用样式时删除 Semi-Hidden 属性。 表示架构中的以下元素标记:w:unhideWhenUsed。 | 
| XmlQualifiedName | 获取当前元素的限定名称。(继承自 OpenXmlElement) | 
| XName | 获取当前元素的限定名称。(继承自 OpenXmlElement) | 
方法
| AddAnnotation(Object) | 将 对象添加到当前 OpenXmlElement 元素的批注列表中。(继承自 OpenXmlElement) | 
| AddChild(OpenXmlElement, Boolean) | 如果指定元素是已知的子元素,则将其添加到 元素。 这会根据架构将 元素添加到正确的位置。(继承自 OpenXmlCompositeElement) | 
| AddNamespaceDeclaration(String, String) | 将命名空间声明添加到当前节点。(继承自 OpenXmlElement) | 
| Ancestors() | 枚举当前元素的所有上级。(继承自 OpenXmlElement) | 
| Ancestors<T>() | 仅枚举具有指定类型的当前元素的上级。(继承自 OpenXmlElement) | 
| Annotation(Type) | 从当前 OpenXmlElement 元素获取指定类型的第一个批注对象。(继承自 OpenXmlElement) | 
| Annotation<T>() | 从当前 OpenXmlElement 元素获取指定类型的第一个批注对象。(继承自 OpenXmlElement) | 
| Annotations(Type) | 获取具有当前 OpenXmlElement 元素的指定类型的批注的集合。(继承自 OpenXmlElement) | 
| Annotations<T>() | 获取具有当前 OpenXmlElement 元素的指定类型的批注的集合。(继承自 OpenXmlElement) | 
| Append(IEnumerable<OpenXmlElement>) | 将元素列表中的每个元素追加到当前元素的子元素列表的末尾。(继承自 OpenXmlElement) | 
| Append(OpenXmlElement[]) | 将元素数组中的每个元素追加到当前元素的子元素列表的末尾。(继承自 OpenXmlElement) | 
| AppendChild<T>(T) | 将指定的元素追加到当前元素的子节点列表的末尾。(继承自 OpenXmlCompositeElement) | 
| ClearAllAttributes() | 清除所有属性,包括已知属性和扩展属性。(继承自 OpenXmlElement) | 
| Clone() | 创建当前节点的副本。(继承自 OpenXmlElement) | 
| CloneNode(Boolean) | 创建此节点的副本。 | 
| Descendants() | 枚举当前元素的所有后代。(继承自 OpenXmlElement) | 
| Descendants<T>() | 枚举类型为 T 的当前元素的所有后代。(继承自 OpenXmlElement) | 
| Elements() | 枚举当前元素的所有子元素。(继承自 OpenXmlElement) | 
| Elements<T>() | 仅枚举具有指定类型的当前元素的子元素。(继承自 OpenXmlElement) | 
| ElementsAfter() | 枚举与当前元素相同的父级的所有同级元素。(继承自 OpenXmlElement) | 
| ElementsBefore() | 枚举当前元素之前且具有与当前元素相同的父级的所有同级元素。(继承自 OpenXmlElement) | 
| GetAttribute(String, String) | 获取具有指定标记名称和命名空间 URI 的 Open XML 属性。(继承自 OpenXmlElement) | 
| GetAttributes() | 获取一个列表,该列表包含所有属性的副本。(继承自 OpenXmlElement) | 
| GetEnumerator() | 返回循环访问子集合的枚举器。(继承自 OpenXmlElement) | 
| GetFirstChild<T>() | 查找类型 T 中的第一个子元素。(继承自 OpenXmlElement) | 
| InsertAfter<T>(T, OpenXmlElement) | 在指定的引用元素之后立即插入指定的元素。(继承自 OpenXmlCompositeElement) | 
| InsertAfterSelf<T>(T) | 在当前元素之后立即插入指定的元素。(继承自 OpenXmlElement) | 
| InsertAt<T>(T, Int32) | 在当前元素的子元素的指定索引处插入指定的元素。(继承自 OpenXmlCompositeElement) | 
| InsertBefore<T>(T, OpenXmlElement) | 将指定的元素紧接在指定的引用元素之前。(继承自 OpenXmlCompositeElement) | 
| InsertBeforeSelf<T>(T) | 将指定的元素紧接在当前元素的前面。(继承自 OpenXmlElement) | 
| IsAfter(OpenXmlElement) | 确定当前元素是否以文档顺序显示在指定元素之后。(继承自 OpenXmlElement) | 
| IsBefore(OpenXmlElement) | 确定当前元素是否按文档顺序显示在指定元素之前。(继承自 OpenXmlElement) | 
| LookupNamespace(String) | 解析当前节点上下文中的命名空间前缀。(继承自 OpenXmlElement) | 
| LookupPrefix(String) | 查找当前元素范围内命名空间 URI 的相应前缀。(继承自 OpenXmlElement) | 
| NextSibling() | 获取紧跟在当前 OpenXmlElement 元素后面的 OpenXmlElement 元素。 如果没有下一个 OpenXmlElement 元素,则返回 null (Visual Basic) Nothing。(继承自 OpenXmlElement) | 
| NextSibling<T>() | 获取具有当前 OpenXmlElement 元素后面的指定类型的 OpenXmlElement 元素。 如果没有下一个 OpenXmlElement,则返回 null (Visual Basic) Nothing。(继承自 OpenXmlElement) | 
| PrependChild<T>(T) | 在当前元素的子节点列表的开头插入指定的元素。(继承自 OpenXmlCompositeElement) | 
| PreviousSibling() | 获取紧接在当前 OpenXmlElement 元素之前的 OpenXmlElement 元素。 如果没有前面的 OpenXmlElement 元素,则返回 null (Visual Basic ) 中 Nothing。(继承自 OpenXmlElement) | 
| PreviousSibling<T>() | 获取位于当前 OpenXmlElement 之前的指定类型的 OpenXmlElement 元素。 如果没有前面的 OpenXmlElement 元素,则返回 null (Visual Basic) Nothing。(继承自 OpenXmlElement) | 
| Remove() | 从其父元素中删除当前元素。(继承自 OpenXmlElement) | 
| RemoveAllChildren() | 删除当前元素的所有子元素。(继承自 OpenXmlCompositeElement) | 
| RemoveAllChildren<T>() | 删除类型为 T 的当前元素的所有子元素。(继承自 OpenXmlElement) | 
| RemoveAnnotations(Type) | 从当前 OpenXmlElement 元素中删除指定类型的注释。(继承自 OpenXmlElement) | 
| RemoveAnnotations<T>() | 从当前 OpenXmlElement 元素中删除具有指定类型的批注。(继承自 OpenXmlElement) | 
| RemoveAttribute(String, String) | 从当前元素中删除 属性。(继承自 OpenXmlElement) | 
| RemoveChild<T>(T) | 删除指定的子元素。(继承自 OpenXmlCompositeElement) | 
| RemoveNamespaceDeclaration(String) | 删除指定前缀的命名空间声明。 如果没有前缀,则不删除任何内容。(继承自 OpenXmlElement) | 
| ReplaceChild<T>(OpenXmlElement, T) | 将当前元素的子元素之一替换为另一个 OpenXmlElement 元素。(继承自 OpenXmlCompositeElement) | 
| SetAttribute(OpenXmlAttribute) | 将特性设置为指定的元素。 如果该属性是已知属性,则设置该特性的值。 如果该属性是扩展属性,则会将“openxmlAttribute”添加到扩展属性列表中。(继承自 OpenXmlElement) | 
| SetAttributes(IEnumerable<OpenXmlAttribute>) | 设置元素的多个属性。 如果属性是已知属性,则会设置该属性的值。 如果属性是扩展属性,则会将“openxmlAttribute”添加到扩展属性列表中。(继承自 OpenXmlElement) | 
| WriteTo(XmlWriter) | 将当前节点保存到指定的 XmlWriter。(继承自 OpenXmlElement) | 
显式接口实现
| IEnumerable.GetEnumerator() | 样式定义。 此类在 Office 2007 及更高版本中可用。 将对象序列化为 xml 时,其限定名称为 w:style。(继承自 OpenXmlElement) | 
| IEnumerable<OpenXmlElement>.GetEnumerator() | 返回循环访问子集合的枚举器。(继承自 OpenXmlElement) |