WordSection
OfficeIMO.Word
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.
Returned or exposed by 5
- Method WordDocument.AddSection
- Method WordDocument.CloneSection
- Property WordDocument.Sections
- Method WordSection.CloneSection
- Method WordSection.SetBorders
Accepted by parameters 4
- Constructor WordMargins.WordMargins
- Constructor WordPageSizes.WordPageSizes
- Method WordParagraph.AddParagraphAfterSelf
- Constructor WordWatermark.WordWatermark
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
- Numbering format.
- position OfficeIMO.Word.WordEndnotePosition? = null
- Document-wide endnote position. A position-only update preserves section numbering.
- restartNumbering OfficeIMO.Word.WordNoteNumberRestart? = null
- Restart numbering option.
- startNumber int? = null
- Starting number.
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
- Numbering format.
- position OfficeIMO.Word.WordFootnotePosition? = null
- Footnote position.
- restartNumbering OfficeIMO.Word.WordNoteNumberRestart? = null
- Restart numbering option.
- startNumber int? = null
- Starting number.
public WordParagraph AddHeaderParagraph(string text = "", bool removeExistingParagraphs = false) #Adds a paragraph to the default section header.
Parameters
- text string = ""
- Paragraph text.
- removeExistingParagraphs bool = false
- True to clear existing paragraphs.
Returns
WordParagraphpublic 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
- Border style of the line.
- color OfficeIMO.OfficeColor? = null
- Line color.
- size uint = 12
- Line width.
- space uint = 1
- Line spacing.
public WordHyperLink AddHyperLink(string text, Uri uri, bool addStyle = false, string tooltip = "", bool history = true) #Adds a hyperlink paragraph pointing to a URI.
Parameters
- text string
- Display text.
- uri System.Uri
- Target URI.
- addStyle bool = false
- Whether to apply hyperlink style.
- tooltip string = ""
- Optional tooltip.
- history bool = true
- Add to document history.
public WordHyperLink AddHyperLink(string text, string anchor, bool addStyle = false, string tooltip = "", bool history = true) #Adds a hyperlink paragraph pointing to an internal anchor.
Parameters
- text string
- Display text.
- anchor string
- Bookmark anchor name.
- addStyle bool = false
- Whether to apply hyperlink style.
- tooltip string = ""
- Optional tooltip.
- history bool = true
- Add to document history.
public WordImage AddImage(string path, OfficeLength? width = null, OfficeLength? height = null, WordImageOptions? options = null) #Adds an image to the section.
Parameters
- path string
- Path to the image file to embed.
- width OfficeIMO.OfficeLength? = null
- Optional displayed image width.
- height OfficeIMO.OfficeLength? = null
- Optional displayed image height.
- options OfficeIMO.Word.WordImageOptions? = null
- Image markup, wrapping and metadata options.
Returns
WordImagepublic WordPageNumberSettings AddPageNumbering(int? startNumber = null, WordNumberFormat? format = null) #Adds or updates page numbering for the section.
Parameters
- startNumber int? = null
- Starting page number.
- format OfficeIMO.Word.WordNumberFormat? = null
- Number format.
public WordParagraph AddParagraph(bool newRun) #Adds a new paragraph to the section.
Parameters
- newRun bool
- Whether to create a run within the paragraph.
public WordParagraph AddParagraph(string text = "") #Adds a new paragraph containing the specified text.
Parameters
- text string = ""
- Text to place in the 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
- Type of shape to create.
- width OfficeIMO.OfficeLength
- Width or line end X.
- height OfficeIMO.OfficeLength
- Height or line end Y.
- fillColor OfficeIMO.OfficeColor? = null
- Fill color; white when omitted.
- strokeColor OfficeIMO.OfficeColor? = null
- Stroke color; black when omitted.
- strokeWeight OfficeIMO.OfficeLength? = null
- Stroke thickness; one point when omitted.
- arcSize double = 0.25
- Rounded corner size expressed as a fraction between 0 and 1.
Returns
WordShapepublic WordShape AddShapeDrawing(WordShapeType shapeType, OfficeLength width, OfficeLength height) #Adds a DrawingML shape to the section.
Parameters
- shapeType OfficeIMO.Word.WordShapeType
- Type of shape to create.
- width OfficeIMO.OfficeLength
- Width.
- height OfficeIMO.OfficeLength
- Height.
Returns
WordShapepublic WordSmartArt AddSmartArt(WordSmartArtType type) #Inserts a SmartArt diagram into this section.
Parameters
- type OfficeIMO.Word.WordSmartArtType
- Layout type of the SmartArt.
public WordTable AddTable(int rows, int columns, WordTableStyle tableStyle = TableGrid) #Adds a table to the section.
Parameters
- rows int
- Number of rows.
- columns int
- Number of columns.
- tableStyle OfficeIMO.Word.WordTableStyle = TableGrid
- Table style to apply.
Returns
WordTablepublic WordTextBox AddTextBox(string text, WordImageTextWrapping wrapTextImage = Square) #Adds a text box paragraph to the section.
Parameters
- text string
- Initial text inside the text box.
- wrapTextImage OfficeIMO.Word.WordImageTextWrapping = Square
- Wrapping style.
public WordTextBox AddTextBoxVml(string text) #Adds a VML text box paragraph to the section.
Parameters
- text string
- Initial text content inserted into the VML text box.
Returns
WordTextBoxpublic 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
- Watermark style.
- textOrFilePath string
- Text or image file path.
- horizontalOffset OfficeIMO.OfficeLength? = null
- Optional signed horizontal offset.
- verticalOffset OfficeIMO.OfficeLength? = null
- Optional signed vertical offset.
- scale double = 1
- Scale factor for width and height.
public WordSection CloneSection() #Creates a copy of this section and inserts it after the current section.
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
- Text to find; a match can span runs and, unless WholeWords is selected, paragraphs in one part.
- options OfficeIMO.OfficeTextSearchOptions? = null
- Comparison settings. Null ignores case and permits matches inside words.
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
- Pattern whose options control comparison and boundaries.
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
- Border preset to apply.
Inherited Methods
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> ParagraphsHyperLinks { get; } #Provides a list of paragraphs that contain hyperlinks.
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<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<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<WordHyperLink> HyperLinks { get; } #Gets all hyperlinks within the section.
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.