api_name | api_type | ms.assetid | title | ms.suite | ms.author | author | ms.topic | ms.date | ms.localizationpriority | ||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
8a9117f7-066e-409c-8681-a26610c0eede |
Working with paragraphs |
office |
o365devx |
o365devx |
conceptual |
11/01/2017 |
high |
This topic discusses the Open XML SDK Paragraph class and how it relates to the Open XML File Format WordprocessingML schema.
The following text from the ISO/IEC 29500 specification introduces the Open XML WordprocessingML element used to represent a paragraph in a WordprocessingML document.
The most basic unit of block-level content within a WordprocessingML document, paragraphs are stored using the <p> element. A paragraph defines a distinct division of content that begins on a new line. A paragraph can contain three pieces of information: optional paragraph properties, inline content (typically runs), and a set of optional revision IDs used to compare the content of two documents.
A paragraph's properties are specified via the <pPr>element. Some examples of paragraph properties are alignment, border, hyphenation override, indentation, line spacing, shading, text direction, and widow/orphan control.
© ISO/IEC29500: 2008.
The following table lists the most common Open XML SDK classes used when working with paragraphs.
WordprocessingML element | Open XML SDK Class |
---|---|
p | Paragraph |
pPr | ParagraphProperties |
r | Run |
t | Text |
The Open XML SDK Paragraph class represents the paragraph (<p>) element defined in the Open XML File Format schema for WordprocessingML documents as discussed above. Use the Paragraph object to manipulate individual <p> elements in a WordprocessingML document.
In WordprocessingML, a paragraph's properties are specified via the paragraph properties (<pPr>) element. Some examples of paragraph properties are alignment, border, hyphenation override, indentation, line spacing, shading, text direction, and widow/orphan control. The OXML SDK ParagraphProperties class represents the <pPr> element.
Paragraphs in a word-processing document most often contain text. In the OXML File Format schema for WordprocessingML documents, the run (<r>) element is provided to demarcate a region of text. The OXML SDK Run class represents the <r> element.
With the <r> element, the text (<t>) element is the container for the text that makes up the document content. The OXML SDK Text class represents the <t> element.
The following code instantiates an Open XML SDKParagraph object and then uses it to add text to a WordprocessingML document.
When this code is run, the following XML is written to the WordprocessingML document referenced in the code.
<w:p>
<w:r>
<w:t>String from WriteToWordDoc method.</w:t>
</w:r>
</w:p>
About the Open XML SDK for Office
How to: Apply a style to a paragraph in a word processing document