相关文章推荐
逆袭的骆驼  ·  python - ValueError: ...·  1 年前    · 
直爽的跑步机  ·  Ubuntu 20.04 ...·  1 年前    · 
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.ParagraphStyleId))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.KeepNext))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.KeepLines))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.PageBreakBefore))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.FrameProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.WidowControl))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.NumberingProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.SuppressLineNumbers))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.ParagraphBorders))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Shading))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Tabs))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.SuppressAutoHyphens))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Kinsoku))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.WordWrap))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.OverflowPunctuation))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TopLinePunctuation))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.AutoSpaceDE))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.AutoSpaceDN))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.BiDi))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.AdjustRightIndent))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.SnapToGrid))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.SpacingBetweenLines))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Indentation))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.ContextualSpacing))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.MirrorIndents))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.SuppressOverlap))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.Justification))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TextDirection))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TextAlignment))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.TextBoxTightWrap))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.OutlineLevel))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.DivId))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.ConditionalFormatStyle))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.ParagraphMarkRunProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.SectionProperties))]
[DocumentFormat.OpenXml.ChildElementInfo(typeof(DocumentFormat.OpenXml.Wordprocessing.ParagraphPropertiesChange))]
public class ParagraphProperties : DocumentFormat.OpenXml.OpenXmlCompositeElement
type ParagraphProperties = class
    inherit OpenXmlCompositeElement
Public Class ParagraphProperties
Inherits OpenXmlCompositeElement
ParagraphProperties

以下示例打开一个现有的字处理文档,搜索一个 Heading1 样式的段落,并在该段落之前插入一个轮廓后代。

using System;  
using System.Collections.Generic;  
using System.Linq;  
using DocumentFormat.OpenXml;  
using DocumentFormat.OpenXml.Packaging;  
using DocumentFormat.OpenXml.Wordprocessing;  
namespace ParagraphPropertiesEx  
    class Program  
        // Search all paragraphs of the specified style and make an outline descendant.  
        static void Main(string[] args)  
            string fileName = @"C:\Users\Public\Documents\ParagraphPropertiesEx.docx";  
            using (WordprocessingDocument wordprocessingDocument =   
                WordprocessingDocument.Open(fileName, true))  
                // Get the body element.  
                var body = wordprocessingDocument.MainDocumentPart.Document.Body;  
                //Define a list to store outline Paragraphs  
                var paragraphs = new List<Paragraph>();  
                // Search all Paragraphs that is "Heading1" style.  
                foreach (Paragraph para in body.Descendants<Paragraph>().  
                    Where(e => e.ParagraphProperties != null  
                        && e.ParagraphProperties.ParagraphStyleId != null  
                        && e.ParagraphProperties.ParagraphStyleId.Val == "Heading1"))  
                    paragraphs.Add(new Paragraph(new Run(new Text(para.InnerText))));  
                // Need to find whether first child is null, if so, add the paragragh collections to Body.  
                if (body.FirstChild == null)  
                    body.Append(paragraphs.ToArray());  
                // Else, get first child and always insert before it.  
                    OpenXmlElement first = body.FirstChild;  
                    foreach (Paragraph p in paragraphs)  
                        first.InsertBeforeSelf<Paragraph>(p);  
            Console.WriteLine("All done. Press a key");  
            Console.ReadKey();  
Imports System.Collections.Generic  
Imports System.Linq  
Imports DocumentFormat.OpenXml  
Imports DocumentFormat.OpenXml.Packaging  
Imports DocumentFormat.OpenXml.Wordprocessing  
Module Module1  
    ' Search all paragraphs of the specified style and make an outline descendant.  
    Sub Main(ByVal args As String())  
        Dim fileName As String = "C:\Users\Public\Documents\ParagraphPropertiesEx.docx"  
        Using wordprocessingDocument As WordprocessingDocument = wordprocessingDocument.Open(fileName, True)  
            ' Get the body element.  
            Dim body = wordprocessingDocument.MainDocumentPart.Document.Body  
            'Define a list to store outline Paragraphs  
            Dim paragraphs = New List(Of Paragraph)()  
            ' Search all Paragraphs that is "Heading1" style.  
            For Each para As Paragraph In body.Descendants(Of Paragraph)().Where(Function(e) e.ParagraphProperties IsNot Nothing AndAlso e.ParagraphProperties.ParagraphStyleId IsNot Nothing AndAlso e.ParagraphProperties.ParagraphStyleId.Val = "Heading1")  
                paragraphs.Add(New Paragraph(New Run(New Text(para.InnerText))))  
            ' Need to find whether first child is null, if so, add the paragragh collections to Body.  
            If body.FirstChild Is Nothing Then  
                body.Append(paragraphs.ToArray())  
                ' Else, get first child and always insert before it.  
                Dim first As OpenXmlElement = body.FirstChild  
                For Each p As Paragraph In paragraphs  
                    first.InsertBeforeSelf(Of Paragraph)(p)  
            End If  
        End Using  
        Console.WriteLine("All done. Press a key")  
        Console.ReadKey()  
    End Sub  
End Module  
	

[ISO/IEC 29500-1 第 1 版]

pPr (段落属性)

此元素指定一组段落属性,在向文本应用所有样式/编号/表属性后,这些属性应应用于父段落的内容。 这些属性定义为 直接格式设置,因为它们直接应用于段落,并取代样式中的任何格式。

[示例:考虑应具有一组段落格式属性的段落。 此属性集在段落属性中指定,如下所示:

<w:pPr> <w:pBdr> <w:bottom w:val="single" w:sz="8" w:space="4" w:color="4F81BD" />   </w:pBdr>   <w:spacing w:after="300" />   <w:contextualSpacing /> </w:pPr>

pPr 元素指定应用于当前段落的属性 - 在本例中, 使用底部元素的底部段落边框 (§17.3.1.7) ,使用间距元素的段落后间距 (§17.3.1.33) ,对于使用上下文元素 (§17.3.1.9) 的相同样式的上方/下方段落,应忽略该间距。 end example]

获取当前 OpenXmlElement 元素的最后一个子元素。 如果没有这样的 OpenXmlElement 元素,则返回 null (Visual Basic) Nothing。

(继承自 OpenXmlCompositeElement)

获取紧跟在当前 OpenXmlElement 元素后面的 OpenXmlElement 元素。 如果没有下一个 OpenXmlElement 元素,则返回 null (Visual Basic) Nothing。

(继承自 OpenXmlElement)

获取具有当前 OpenXmlElement 元素后面的指定类型的 OpenXmlElement 元素。 如果没有下一个 OpenXmlElement,则返回 null (Visual Basic) Nothing。

(继承自 OpenXmlElement)

获取紧接在当前 OpenXmlElement 元素之前的 OpenXmlElement 元素。 如果没有前面的 OpenXmlElement 元素,则返回 null (Visual Basic ) 中 Nothing。

(继承自 OpenXmlElement)

获取位于当前 OpenXmlElement 之前的指定类型的 OpenXmlElement 元素。 如果没有前面的 OpenXmlElement 元素,则返回 null (Visual Basic) Nothing。

(继承自 OpenXmlElement)

将特性设置为指定的元素。 如果该属性是已知属性,则设置该特性的值。 如果该属性是扩展属性,则会将“openxmlAttribute”添加到扩展属性列表中。

(继承自 OpenXmlElement)

设置元素的多个属性。 如果属性是已知属性,则会设置该特性的值。 如果属性是扩展属性,则会将“openxmlAttribute”添加到扩展属性列表中。

(继承自 OpenXmlElement)