API Reference
WordSection
Represents a section within a Word document.
Inheritance
- Object
- WordSection
Constructors
WordSection(OfficeIMO.Word.WordDocument wordDocument, DocumentFormat.OpenXml.Wordprocessing.SectionProperties sectionProperties, DocumentFormat.OpenXml.Wordprocessing.Paragraph paragraph) #Used to load WordSection withing word document
Parameters
- wordDocument OfficeIMO.Word.WordDocument
- sectionProperties DocumentFormat.OpenXml.Wordprocessing.SectionProperties
- paragraph DocumentFormat.OpenXml.Wordprocessing.Paragraph
Exceptions
NotImplementedException
WordSection(OfficeIMO.Word.WordDocument wordDocument, DocumentFormat.OpenXml.Wordprocessing.Paragraph paragraph) #Used for creating WordSection in new documents
Parameters
- wordDocument OfficeIMO.Word.WordDocument
- paragraph DocumentFormat.OpenXml.Wordprocessing.Paragraph
Methods
public WordSection AddEndnoteProperties(Nullable<NumberFormatValues> numberingFormat = null, Nullable<EndnotePositionValues> position = null, Nullable<RestartNumberValues> restartNumbering = null, Nullable<Int32> startNumber = null) #WordSectionConfigures endnote properties for the section.
Parameters
- numberingFormat System.Nullable{DocumentFormat.OpenXml.Wordprocessing.NumberFormatValues} = null
- Numbering format.
- position System.Nullable{DocumentFormat.OpenXml.Wordprocessing.EndnotePositionValues} = null
- Endnote position.
- restartNumbering System.Nullable{DocumentFormat.OpenXml.Wordprocessing.RestartNumberValues} = null
- Restart numbering option.
- startNumber System.Nullable{System.Int32} = null
- Starting number.
Returns
The current section.
public WordSection AddFootnoteProperties(Nullable<NumberFormatValues> numberingFormat = null, Nullable<FootnotePositionValues> position = null, Nullable<RestartNumberValues> restartNumbering = null, Nullable<Int32> startNumber = null) #WordSectionConfigures footnote properties for the section.
Parameters
- numberingFormat System.Nullable{DocumentFormat.OpenXml.Wordprocessing.NumberFormatValues} = null
- Numbering format.
- position System.Nullable{DocumentFormat.OpenXml.Wordprocessing.FootnotePositionValues} = null
- Footnote position.
- restartNumbering System.Nullable{DocumentFormat.OpenXml.Wordprocessing.RestartNumberValues} = null
- Restart numbering option.
- startNumber System.Nullable{System.Int32} = null
- Starting number.
Returns
The current section.
public WordParagraph AddHeaderParagraph(String text = "", Boolean removeExistingParagraphs = false) #WordParagraphAdds a paragraph to the default section header.
Parameters
- text System.String = ""
- Paragraph text.
- removeExistingParagraphs System.Boolean = false
- True to clear existing paragraphs.
public WordParagraph AddHorizontalLine(Nullable<BorderValues> lineType = null, Nullable<Color> color = null, UInt32 size = 12, UInt32 space = 1) #WordParagraphInserts a horizontal line paragraph into the section.
Parameters
- lineType System.Nullable{DocumentFormat.OpenXml.Wordprocessing.BorderValues} = null
- Border style of the line.
- color System.Nullable{SixLabors.ImageSharp.Color} = null
- Line color.
- size System.UInt32 = 12
- Line width.
- space System.UInt32 = 1
- Line spacing.
Returns
The paragraph containing the line.
public WordParagraph AddHyperLink(String text, Uri uri, Boolean addStyle = false, String tooltip = "", Boolean history = true) #WordParagraphAdds a hyperlink paragraph pointing to a URI.
Parameters
- text System.String
- Display text.
- uri System.Uri
- Target URI.
- addStyle System.Boolean = false
- Whether to apply hyperlink style.
- tooltip System.String = ""
- Optional tooltip.
- history System.Boolean = true
- Add to document history.
Returns
The created paragraph.
public WordParagraph AddHyperLink(String text, String anchor, Boolean addStyle = false, String tooltip = "", Boolean history = true) #WordParagraphAdds a hyperlink paragraph pointing to an internal anchor.
Parameters
- text System.String
- Display text.
- anchor System.String
- Bookmark anchor name.
- addStyle System.Boolean = false
- Whether to apply hyperlink style.
- tooltip System.String = ""
- Optional tooltip.
- history System.Boolean = true
- Add to document history.
Returns
The created paragraph.
public WordImage AddImageVml(String filePathImage, Nullable<Double> width = null, Nullable<Double> height = null) #WordImageAdds a VML image to the section.
Parameters
- filePathImage System.String
- Path to the image file to embed.
- width System.Nullable{System.Double} = null
- Optional image width in points.
- height System.Nullable{System.Double} = null
- Optional image height in points.
public WordSection AddPageNumbering(Nullable<Int32> startNumber = null, Nullable<NumberFormatValues> format = null) #WordSectionAdds or updates page numbering for the section.
Parameters
- startNumber System.Nullable{System.Int32} = null
- Starting page number.
- format System.Nullable{DocumentFormat.OpenXml.Wordprocessing.NumberFormatValues} = null
- Number format.
Returns
The current section.
public WordParagraph AddParagraph(Boolean newRun) #WordParagraphAdds a new paragraph to the section.
Parameters
- newRun System.Boolean
- Whether to create a run within the paragraph.
Returns
The created paragraph.
public WordParagraph AddParagraph(String text = "") #WordParagraphAdds a new paragraph containing the specified text.
Parameters
- text System.String = ""
- Text to place in the paragraph.
Returns
The created paragraph.
public WordShape AddShape(ShapeType shapeType, Double widthPt, Double heightPt, Color fillColor, Color strokeColor, Double strokeWeightPt = 1, Double arcSize = 0.25) #WordShapeAdds a VML shape to the section.
Parameters
- shapeType OfficeIMO.Word.ShapeType
- Type of shape to create.
- widthPt System.Double
- Width in points or line end X.
- heightPt System.Double
- Height in points or line end Y.
- fillColor System.String = "#FFFFFF"
- Fill color specified as a hex string (for example, #RRGGBB).
- strokeColor System.String = "#000000"
- Stroke color specified as a hex string (for example, #RRGGBB).
- strokeWeightPt System.Double = 1
- Stroke weight in points.
- arcSize System.Double = 0.25
- Rounded corner size expressed as a fraction between 0 and 1.
AddShape(OfficeIMO.Word.ShapeType shapeType, System.Double widthPt, System.Double heightPt, SixLabors.ImageSharp.Color fillColor, SixLabors.ImageSharp.Color strokeColor, System.Double strokeWeightPt, System.Double arcSize) #Adds a VML shape to the section using Color values.
Parameters
- shapeType OfficeIMO.Word.ShapeType
- widthPt System.Double
- heightPt System.Double
- fillColor SixLabors.ImageSharp.Color
- strokeColor SixLabors.ImageSharp.Color
- strokeWeightPt System.Double
- arcSize System.Double
public WordShape AddShapeDrawing(ShapeType shapeType, Double widthPt, Double heightPt) #WordShapeAdds a DrawingML shape to the section.
Parameters
- shapeType OfficeIMO.Word.ShapeType
- Type of shape to create.
- widthPt System.Double
- Width in points.
- heightPt System.Double
- Height in points.
public WordSmartArt AddSmartArt(SmartArtType type) #WordSmartArtInserts a SmartArt diagram into this section.
Parameters
- type OfficeIMO.Word.SmartArtType
- Layout type of the SmartArt.
Returns
The created WordSmartArt.
public WordTable AddTable(Int32 rows, Int32 columns, WordTableStyle tableStyle = TableGrid) #WordTableAdds a table to the section.
Parameters
- rows System.Int32
- Number of rows.
- columns System.Int32
- Number of columns.
- tableStyle OfficeIMO.Word.WordTableStyle = TableGrid
- Table style to apply.
public WordTextBox AddTextBox(String text, WrapTextImage wrapTextImage = Square) #WordTextBoxAdds a text box paragraph to the section.
Parameters
- text System.String
- Initial text inside the text box.
- wrapTextImage OfficeIMO.Word.WrapTextImage = Square
- Wrapping style.
Returns
The created WordTextBox.
public WordTextBox AddTextBoxVml(String text) #WordTextBoxAdds a VML text box paragraph to the section.
Parameters
- text System.String
- Initial text content inserted into the VML text box.
public WordWatermark AddWatermark(WordWatermarkStyle watermarkStyle, String textOrFilePath, Nullable<Double> horizontalOffset = null, Nullable<Double> verticalOffset = null, Double scale = 1) #WordWatermarkAdds a watermark to the section.
Parameters
- watermarkStyle OfficeIMO.Word.WordWatermarkStyle
- Watermark style.
- textOrFilePath System.String
- Text or image file path.
- horizontalOffset System.Nullable{System.Double} = null
- Horizontal offset in points.
- verticalOffset System.Nullable{System.Double} = null
- Vertical offset in points.
- scale System.Double = 1
- Scale factor for width and height.
Returns
The created WordWatermark instance.
AppendParagraphToSection(OfficeIMO.Word.WordParagraph wordParagraph) #Appends the provided paragraph to the end of this section in the document body.
Parameters
- wordParagraph OfficeIMO.Word.WordParagraph
- Paragraph to append.
public WordSection CloneSection() #WordSectionCreates a copy of this section and inserts it after the current section.
Returns
The cloned WordSection.
ConvertParagraphsToWordParagraphs(OfficeIMO.Word.WordDocument document, System.Collections.Generic.IEnumerable{DocumentFormat.OpenXml.Wordprocessing.Paragraph} paragraphs) #Converts paragraphs to WordParagraphs
Parameters
- document OfficeIMO.Word.WordDocument
- paragraphs System.Collections.Generic.IEnumerable{DocumentFormat.OpenXml.Wordprocessing.Paragraph}
ConvertParagraphToWordParagraphs(OfficeIMO.Word.WordDocument document, DocumentFormat.OpenXml.Wordprocessing.Paragraph paragraph) #Converts paragraph to WordParagraphs
Parameters
- document OfficeIMO.Word.WordDocument
- paragraph DocumentFormat.OpenXml.Wordprocessing.Paragraph
ConvertStdBlockToCoverPage(OfficeIMO.Word.WordDocument document, System.Collections.Generic.IEnumerable{DocumentFormat.OpenXml.Wordprocessing.SdtBlock} sdtBlocks) #Converts StdBlock to WordCoverPage
Parameters
- document OfficeIMO.Word.WordDocument
- sdtBlocks System.Collections.Generic.IEnumerable{DocumentFormat.OpenXml.Wordprocessing.SdtBlock}
ConvertStdBlockToTableOfContent(OfficeIMO.Word.WordDocument document, System.Collections.Generic.IEnumerable{DocumentFormat.OpenXml.Wordprocessing.SdtBlock} sdtBlocks) #Converts StdBlock to WordTableOfContent
Parameters
- document OfficeIMO.Word.WordDocument
- sdtBlocks System.Collections.Generic.IEnumerable{DocumentFormat.OpenXml.Wordprocessing.SdtBlock}
ConvertStdBlockToWatermark(OfficeIMO.Word.WordDocument document, System.Collections.Generic.IEnumerable{DocumentFormat.OpenXml.Wordprocessing.SdtBlock} sdtBlock) #Converts SdtBlock to WordWatermark if it's a watermark Hopefully detection is good enough, but it's possible that it will catch other things as well
Parameters
- document OfficeIMO.Word.WordDocument
- sdtBlock System.Collections.Generic.IEnumerable{DocumentFormat.OpenXml.Wordprocessing.SdtBlock}
ConvertStdBlockToWatermark(OfficeIMO.Word.WordDocument document, DocumentFormat.OpenXml.Wordprocessing.SdtBlock sdtBlock) #Converts SdtBlock to WordWatermark if it's a watermark
Parameters
- document OfficeIMO.Word.WordDocument
- sdtBlock DocumentFormat.OpenXml.Wordprocessing.SdtBlock
ConvertStdBlockToWordElements(OfficeIMO.Word.WordDocument document, DocumentFormat.OpenXml.Wordprocessing.SdtBlock sdtBlock) #Converts StdBlock to WordElement
Parameters
- document OfficeIMO.Word.WordDocument
- sdtBlock DocumentFormat.OpenXml.Wordprocessing.SdtBlock
ConvertStdBlockToWordElements(OfficeIMO.Word.WordDocument document, System.Collections.Generic.IEnumerable{DocumentFormat.OpenXml.Wordprocessing.SdtBlock} sdtBlocks) #Converts StdBlock to WordElement
Parameters
- document OfficeIMO.Word.WordDocument
- sdtBlocks System.Collections.Generic.IEnumerable{DocumentFormat.OpenXml.Wordprocessing.SdtBlock}
ConvertTableToWordTable(OfficeIMO.Word.WordDocument document, System.Collections.Generic.IEnumerable{DocumentFormat.OpenXml.Wordprocessing.Table} tables) #Converts tables to WordTables
Parameters
- document OfficeIMO.Word.WordDocument
- tables System.Collections.Generic.IEnumerable{DocumentFormat.OpenXml.Wordprocessing.Table}
CopySectionProperties(DocumentFormat.OpenXml.Wordprocessing.SectionProperties sectionProperties, DocumentFormat.OpenXml.Wordprocessing.SectionProperties newSectionProperties) #This method moves headers and footers and title page to section before it. It also copies all other parts of sections (PageSize,PageMargin and others) to section before it. This is because headers/footers when applied to section apply to the rest of the document unless there are headers/footers on next section. On the other hand page size doesn't apply to other sections and word uses default values.
Parameters
- sectionProperties DocumentFormat.OpenXml.Wordprocessing.SectionProperties
- newSectionProperties DocumentFormat.OpenXml.Wordprocessing.SectionProperties
GetAllDocumentsLists(OfficeIMO.Word.WordDocument document) #This method gets all lists for given document (for all sections)
Parameters
- document OfficeIMO.Word.WordDocument
GetEmbeddedDocumentsList() #Gets list of embedded documents in given section
GetLists() #This method gets lists for given section. It's possible that given list spreads thru multiple sections. Therefore sum of all sections lists doesn't necessary match all lists count for a document.
GetParagraphsList() #Get all paragraphs in given section
GetSdtBlockList() #Gets list of watermarks in given section
GetTablesList() #Gets list of tables in given section
GetWordElements() #Gets list of word elements in given section
GetWordElementsByType() #Gets list of word elements by type in given section
public Void RemoveSection() #VoidRemoves this section and all of its content from the document, cleaning up numbering and any unreferenced header and footer parts.
public Void RemoveWatermark() #VoidRemoves all watermarks from this section including headers.
public WordSection SetBorders(WordBorder wordBorder) #WordSectionApplies border settings to the section.
Parameters
- wordBorder OfficeIMO.Word.WordBorder
- Border preset to apply.
Returns
The current section.
public WordSection SetMargins(WordMargin pageMargins) #WordSectionUpdates the margins for this section.
Parameters
- pageMargins OfficeIMO.Word.WordMargin
- Margin values to apply.
Returns
The current section.
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
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<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 all end notes within the section.
public List<WordFootNote> FootNotes { get; } #Gets all foot notes within the section.
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; set; } #Provides access to page border settings for this section.
public WordMargins Margins { get; set; } #Provides access to page margin settings for this section.
public WordPageSizes PageSettings { get; set; } #Provides access to page size and orientation settings for 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 Boolean DifferentFirstPage { get; set; } #Gets or sets a value indicating whether the first page has different headers and footers.
public Boolean DifferentOddAndEvenPages { get; set; } #Gets or sets a value indicating whether odd and even pages use separate headers and footers.
public Boolean RtlGutter { get; set; } #Gets or sets a value indicating whether the gutter should be on the right for RTL pages.
public PageOrientationValues PageOrientation { get; set; } #Gets or sets the page orientation of the section.
public Nullable<Int32> ColumnsSpace { get; set; } #Gets or sets spacing between section columns.
public Nullable<Int32> ColumnCount { get; set; } #Gets or sets the number of columns in the section.
public Boolean HasColumnSeparator { get; set; } #Gets or sets whether a separator line is shown between section columns.
public FootnoteProperties FootnoteProperties { get; set; } #Gets or sets the footnote properties for the section.
public EndnoteProperties EndnoteProperties { get; set; } #Gets or sets the endnote properties for the section.
public PageNumberType PageNumberType { get; set; } #Gets or sets the page numbering configuration for the section.
Fields
public WordHeaders Header #Exposes the headers available for this section.