Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

WordSection

OfficeIMO.Word

Namespace
OfficeIMO.Word
Assembly
OfficeIMO.Word
Source revision
0eef6a5756b9 with working tree changes

Represents a section within a Word document.

Inheritance

  • object
  • WordSection

Usage

Explore 9 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 4

Methods

public WordEndnoteSettings AddEndnoteProperties(WordNumberFormat? numberingFormat = null, WordEndnotePosition? position = null, WordNoteNumberRestart? restartNumbering = null, int? startNumber = null) #

Configures endnote numbering for the section and placement for the whole document.

Parameters

numberingFormat OfficeIMO.Word.WordNumberFormat? = null optional
Numbering format.
position OfficeIMO.Word.WordEndnotePosition? = null optional
Document-wide endnote position. A position-only update preserves section numbering.
restartNumbering OfficeIMO.Word.WordNoteNumberRestart? = null optional
Restart numbering option.
startNumber int? = null optional
Starting number.

Returns

WordEndnoteSettings The attached, editable numbering settings.
AddFooterParagraph 2 overloads
public WordParagraph AddFooterParagraph(string text, WordHeaderFooterType type, bool removeExistingParagraphs = false) #

Adds a paragraph to the section footer of the requested type.

Parameters

text string required
type OfficeIMO.Word.WordHeaderFooterType required
removeExistingParagraphs bool = false optional
public WordParagraph AddFooterParagraph(string text = "", bool removeExistingParagraphs = false) #

Adds a paragraph to the default section footer.

Parameters

text string = "" optional
Paragraph text.
removeExistingParagraphs bool = false optional
True to clear existing paragraphs.
public WordFootnoteSettings AddFootnoteProperties(WordNumberFormat? numberingFormat = null, WordFootnotePosition? position = null, WordNoteNumberRestart? restartNumbering = null, int? startNumber = null) #

Configures footnote properties for the section.

Parameters

numberingFormat OfficeIMO.Word.WordNumberFormat? = null optional
Numbering format.
position OfficeIMO.Word.WordFootnotePosition? = null optional
Footnote position.
restartNumbering OfficeIMO.Word.WordNoteNumberRestart? = null optional
Restart numbering option.
startNumber int? = null optional
Starting number.

Returns

WordFootnoteSettings The attached, editable numbering settings.
AddHeaderParagraph 2 overloads
public WordParagraph AddHeaderParagraph(string text, WordHeaderFooterType type, bool removeExistingParagraphs = false) #

Adds a paragraph to the section header of the requested type.

Parameters

text string required
type OfficeIMO.Word.WordHeaderFooterType required
removeExistingParagraphs bool = false optional
public WordParagraph AddHeaderParagraph(string text = "", bool removeExistingParagraphs = false) #

Adds a paragraph to the default section header.

Parameters

text string = "" optional
Paragraph text.
removeExistingParagraphs bool = false optional
True to clear existing paragraphs.
public WordParagraph AddHorizontalLine(WordBorderStyle? lineType = null, OfficeColor? color = null, uint size = 12, uint space = 1) #

Inserts a horizontal line paragraph into the section.

Parameters

lineType OfficeIMO.Word.WordBorderStyle? = null optional
Border style of the line.
color OfficeIMO.OfficeColor? = null optional
Line color.
size uint = 12 optional
Line width.
space uint = 1 optional
Line spacing.

Returns

WordParagraph The paragraph containing the line.
AddHyperLink 2 overloads
public WordImage AddImage(string path, OfficeLength? width = null, OfficeLength? height = null, WordImageOptions? options = null) #

Adds an image to the section.

Parameters

path string required
Path to the image file to embed.
width OfficeIMO.OfficeLength? = null optional
Optional displayed image width.
height OfficeIMO.OfficeLength? = null optional
Optional displayed image height.
options OfficeIMO.Word.WordImageOptions? = null optional
Image markup, wrapping and metadata options.

Returns

WordImage
public WordPageNumberSettings AddPageNumbering(int? startNumber = null, WordNumberFormat? format = null) #

Adds or updates page numbering for the section.

Parameters

startNumber int? = null optional
Starting page number.
format OfficeIMO.Word.WordNumberFormat? = null optional
Number format.

Returns

WordPageNumberSettings The attached, editable numbering settings.
AddParagraph 2 overloads
public WordParagraph AddParagraph(bool newRun) #

Adds a new paragraph to the section.

Parameters

newRun bool required
Whether to create a run within the paragraph.

Returns

WordParagraph The created paragraph.
public WordParagraph AddParagraph(string text = "") #

Adds a new paragraph containing the specified text.

Parameters

text string = "" optional
Text to place in the paragraph.

Returns

WordParagraph The created paragraph.
public WordShape AddShape(WordShapeType shapeType, OfficeLength width, OfficeLength height, OfficeColor? fillColor = null, OfficeColor? strokeColor = null, OfficeLength? strokeWeight = null, double arcSize = 0.25) #

Adds a VML shape to the section.

Parameters

shapeType OfficeIMO.Word.WordShapeType required
Type of shape to create.
width OfficeIMO.OfficeLength required
Width or line end X.
height OfficeIMO.OfficeLength required
Height or line end Y.
fillColor OfficeIMO.OfficeColor? = null optional
Fill color; white when omitted.
strokeColor OfficeIMO.OfficeColor? = null optional
Stroke color; black when omitted.
strokeWeight OfficeIMO.OfficeLength? = null optional
Stroke thickness; one point when omitted.
arcSize double = 0.25 optional
Rounded corner size expressed as a fraction between 0 and 1.

Returns

WordShape
public WordShape AddShapeDrawing(WordShapeType shapeType, OfficeLength width, OfficeLength height) #

Adds a DrawingML shape to the section.

Parameters

shapeType OfficeIMO.Word.WordShapeType required
Type of shape to create.
width OfficeIMO.OfficeLength required
Width.
height OfficeIMO.OfficeLength required
Height.

Returns

WordShape
public WordSmartArt AddSmartArt(WordSmartArtType type) #

Inserts a SmartArt diagram into this section.

Parameters

type OfficeIMO.Word.WordSmartArtType required
Layout type of the SmartArt.

Returns

WordSmartArt The created WordSmartArt.
public WordTable AddTable(int rows, int columns, WordTableStyle tableStyle = TableGrid) #

Adds a table to the section.

Parameters

rows int required
Number of rows.
columns int required
Number of columns.
tableStyle OfficeIMO.Word.WordTableStyle = TableGrid optional
Table style to apply.

Returns

WordTable
public WordTextBox AddTextBox(string text, WordImageTextWrapping wrapTextImage = Square) #

Adds a text box paragraph to the section.

Parameters

text string required
Initial text inside the text box.
wrapTextImage OfficeIMO.Word.WordImageTextWrapping = Square optional
Wrapping style.

Returns

WordTextBox The created WordTextBox.
public WordTextBox AddTextBoxVml(string text) #

Adds a VML text box paragraph to the section.

Parameters

text string required
Initial text content inserted into the VML text box.
public WordWatermark AddWatermark(WordWatermarkStyle watermarkStyle, string textOrFilePath, OfficeLength? horizontalOffset = null, OfficeLength? verticalOffset = null, double scale = 1) #

Adds a watermark to the section.

Parameters

watermarkStyle OfficeIMO.Word.WordWatermarkStyle required
Watermark style.
textOrFilePath string required
Text or image file path.
horizontalOffset OfficeIMO.OfficeLength? = null optional
Optional signed horizontal offset.
verticalOffset OfficeIMO.OfficeLength? = null optional
Optional signed vertical offset.
scale double = 1 optional
Scale factor for width and height.

Returns

WordWatermark The created WordWatermark instance.
public WordSection CloneSection() #

Creates a copy of this section and inserts it after the current section.

Returns

WordSection The cloned WordSection.
Find 2 overloads
public WordSearchResult Find(string text, OfficeTextSearchOptions? options = null) #

Finds literal text in this section's body, tables, and resolved headers and footers using the native search groups.

Parameters

text string required
Text to find; a match can span runs and, unless WholeWords is selected, paragraphs in one part.
options OfficeIMO.OfficeTextSearchOptions? = null optional
Comparison settings. Null ignores case and permits matches inside words.

Returns

WordSearchResult Paragraphs containing matches, grouped by part, and the total match count.
public WordSearchResult Find(Regex pattern) #

Finds regular-expression matches within individual paragraphs in this section's body, tables, and resolved headers and footers.

Parameters

pattern System.Text.RegularExpressions.Regex required
Pattern whose options control comparison and boundaries.

Returns

WordSearchResult Paragraphs containing matches, grouped by part, and the total match count.
public void RemoveSection() #

Removes this section and all of its content from the document, cleaning up numbering and any unreferenced header and footer parts.

public void RemoveWatermark() #

Removes all watermarks from this section including headers.

public WordSection SetBorders(WordBorder wordBorder) #

Applies border settings to the section.

Parameters

wordBorder OfficeIMO.Word.WordBorder required
Border preset to apply.

Returns

WordSection The current section.

Properties

public IReadOnlyList<WordSectionColumn> ColumnDefinitions { get; set; } #

Gets or replaces explicit section column widths and individual gaps. Setting a non-empty list selects unequal-width columns and synchronizes ColumnCount. An empty list restores equal-width columns while retaining their count and default gap. An omitted individual gap is zero for unequal columns; ColumnsSpace applies to equal widths. DOCX preserves the omission; native DOC writes its effective zero explicitly. Native DOC saving supports up to 44 columns, widths from 718 through 32767 twips, and gaps from zero through 32767 twips.

public List<WordElement> Elements { get; } #

Provides a list of all elements within the section including paragraphs, tables, images, etc.

public List<WordElement> ElementsByType { get; } #

Provides a list of all elements within the section including paragraphs, tables, images, etc.

public List<WordParagraph> Paragraphs { get; } #

Provides a list of all paragraphs within the section

public List<WordParagraph> ParagraphsPageBreaks { get; } #

Provides a list of all paragraphs with page breaks within the section

public List<WordParagraph> ParagraphsBreaks { get; } #

Provides a list of all paragraphs with breaks within the section

public List<WordParagraph> ParagraphsFields { get; } #

Provides a list of paragraphs that contain fields.

public List<WordParagraph> ParagraphsBookmarks { get; } #

Provides a list of paragraphs that contain Bookmarks

public List<WordParagraph> ParagraphsEquations { get; } #

Provies a list of paragraphs that contain Equations

public List<WordParagraph> ParagraphsTabs { get; } #

Provies a list of paragraphs that contain Tabs

public List<WordParagraph> ParagraphsTabStops { get; } #

Provides a list of paragraphs that contain TabStops

public List<WordParagraph> ParagraphsStructuredDocumentTags { get; } #

Provides a list of paragraphs that contain Structured Document Tags

public List<WordParagraph> ParagraphsCheckBoxes { get; } #

Provides a list of paragraphs that contain checkbox controls

public List<WordParagraph> ParagraphsDatePickers { get; } #

Provides a list of paragraphs that contain date picker controls

public List<WordParagraph> ParagraphsDropDownLists { get; } #

Provides a list of paragraphs that contain dropdown list controls

public List<WordParagraph> ParagraphsComboBoxes { get; } #

Provides a list of paragraphs that contain combo box controls

public List<WordParagraph> ParagraphsPictureControls { get; } #

Provides a list of paragraphs that contain picture controls

public List<WordParagraph> ParagraphsRepeatingSections { get; } #

Provides a list of paragraphs that contain repeating section controls

public List<WordParagraph> ParagraphsImages { get; } #

Provides a list of paragraphs that contain Image

public List<WordParagraph> ParagraphsEmbeddedObjects { get; } #

Provides a list of paragraphs that contain embedded objects.

public List<WordParagraph> ParagraphsCharts { get; } #

Provides a list of paragraphs that contain charts.

public List<WordParagraph> ParagraphsEndNotes { get; } #

Provides a list of paragraphs that contain end notes.

public List<WordParagraph> ParagraphsFootNotes { get; } #

Provides a list of paragraphs that contain foot notes.

public List<WordParagraph> ParagraphsTextBoxes { get; } #

Provides a list of paragraphs that contain text boxes.

public List<WordParagraph> ParagraphsShapes { get; } #

Provides a list of paragraphs that contain shapes.

public List<WordParagraph> ParagraphsSmartArts { get; } #

Provides a list of paragraphs that contain SmartArt diagrams.

public List<WordBreak> PageBreaks { get; } #

Gets all page break objects within the section.

public List<WordChart> Charts { get; } #

Gets all charts contained in the section.

public List<WordBreak> Breaks { get; } #

Gets all line breaks within the section.

public List<WordImage> Images { get; } #

Exposes Images in their Image form for easy access (saving, modifying)

public List<WordEmbeddedObject> EmbeddedObjects { get; } #

Gets all embedded objects within the section.

public List<WordBookmark> Bookmarks { get; } #

Gets all bookmarks defined in the section.

public List<WordField> Fields { get; } #

Gets all fields within the section.

public List<WordEndNote> EndNotes { get; } #

Gets endnotes referenced in the section's body, including tables and content controls, in source order.

public List<WordFootNote> FootNotes { get; } #

Gets footnotes referenced in the section's body, including tables and content controls, in source order.

public List<WordTabChar> Tabs { get; } #

Gets all tab characters defined in the section.

public List<WordTextBox> TextBoxes { get; } #

Gets all text boxes within the section.

public List<WordShape> Shapes { get; } #

Collection of shapes available within the section.

public List<WordSmartArt> SmartArts { get; } #

Collection of SmartArt diagrams available within the section.

public List<WordEquation> Equations { get; } #

Gets all equations within the section.

public List<WordStructuredDocumentTag> StructuredDocumentTags { get; } #

Gets all structured document tags within the section.

public List<WordCheckBox> CheckBoxes { get; } #

Gets all checkbox content controls within the section.

public List<WordDatePicker> DatePickers { get; } #

Gets all date picker content controls within the section.

public List<WordDropDownList> DropDownLists { get; } #

Gets all dropdown list content controls within the section.

public List<WordComboBox> ComboBoxes { get; } #

Gets all combo box content controls within the section.

public List<WordPictureControl> PictureControls { get; } #

Gets all picture content controls within the section.

public List<WordRepeatingSection> RepeatingSections { get; } #

Gets all repeating section content controls within the section.

public WordBorders Borders { get; internal set; } #

Provides access to page border settings for this section.

public WordPageSetup PageSetup { get; } #

Gets the page size, margins, orientation and running headers and footers of this section.

public List<WordList> Lists { get; } #

Provides a list of all lists within the section

public List<WordTable> Tables { get; } #

Provides a list of all tables within the section, excluding nested tables

public List<WordEmbeddedDocument> EmbeddedDocuments { get; } #

Provides a list of all embedded documents within the section

public List<WordWatermark> Watermarks { get; } #

Provides a list of all watermarks within the section, including any watermarks found in the section headers.

public List<WordTable> TablesIncludingNestedTables { get; } #

Provides a list of all tables within the section, including nested tables

public bool RtlGutter { get; set; } #

Gets or sets a value indicating whether the gutter should be on the right for RTL pages.

public OfficeLength? ColumnsSpace { get; set; } #

Gets or sets the equal-width column gap as a physical length. Null omits the stored gap; layout uses its existing 36-point default. Storage rounds to whole signed 32-bit twips. Native DOC saving accepts only gaps from zero through 65535 twips and writes its default for an omitted gap when a column count is set. Individual unequal-column gaps are controlled by ColumnDefinitions.

Exceptions

  • OverflowException – The rounded gap exceeds the signed 32-bit twip range.
public int? ColumnCount { get; set; } #

Gets or sets the number of columns in the section.

public bool HasColumnSeparator { get; set; } #

Gets or sets whether a separator line is shown between section columns.

public WordSectionBreakType BreakType { get; set; } #

Gets or sets how this section starts relative to the preceding section. An omitted section type uses WordSectionBreakType.NextPage.

public WordPageNumberSettings PageNumberSettings { get; } #

Gets the editable configuration of the section's page-numbering configuration.

public WordFootnoteSettings FootnoteSettings { get; } #

Gets the editable configuration of the section's footnote configuration.

public WordEndnoteSettings EndnoteSettings { get; } #

Gets the editable configuration of section numbering and document-wide endnote placement.