API Reference
WordTableOfContent
Represents a table of contents within a Word document.
Inheritance
- WordElement
- WordTableOfContent
Constructors
public WordTableOfContent(WordDocument wordDocument, TableOfContentStyle tableOfContentStyle, Int32 minLevel = 1, Int32 maxLevel = 3) #Initializes a new instance of the WordTableOfContent class and appends it to the document body.
Parameters
- wordDocument OfficeIMO.Word.WordDocument
- Parent document where the table of contents will be created.
- tableOfContentStyle OfficeIMO.Word.TableOfContentStyle
- Template style used to generate the table of contents.
- minLevel System.Int32 = 1
- Minimum heading level to include (1..9).
- maxLevel System.Int32 = 3
- Maximum heading level to include (1..9).
public WordTableOfContent(WordDocument wordDocument, SdtBlock sdtBlock) #Initializes a new instance of the WordTableOfContent class using an existing structured document tag.
Parameters
- wordDocument OfficeIMO.Word.WordDocument
- Parent document that owns the table of contents.
- sdtBlock DocumentFormat.OpenXml.Wordprocessing.SdtBlock
- Structured document tag representing the table of contents.
Methods
MarkFieldsAsDirty() #Marks all fields that participate in the table of contents as dirty so Word refreshes them on open.
Returns
true when an update should be queued. This includes corrupted tables of contents that no longer expose any fields so the caller can still request a refresh without throwing.
PrepareTemplate(OfficeIMO.Word.WordDocument document, OfficeIMO.Word.TableOfContentStyle style) #Returns a predefined structured document tag matching the chosen style.
Parameters
- document OfficeIMO.Word.WordDocument
- Document that will own the structured document tag.
- style OfficeIMO.Word.TableOfContentStyle
- Template identifier to retrieve.
public WordTableOfContent Regenerate() #WordTableOfContentRemoves this table of contents and creates a new one in the same location.
Returns
The newly created WordTableOfContent instance.
public Void SetLevels(Int32 minLevel, Int32 maxLevel) #VoidUpdates the heading levels included by the TOC field switch (for example: \o "1-5").
Parameters
- minLevel System.Int32
- Minimum heading level to include (1..9).
- maxLevel System.Int32
- Maximum heading level to include (1..9).
public Void Update() #VoidFlags the document to update this table of contents when the file is opened.
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
SdtBlock #Exposes the underlying structured document tag for this table of contents.
public TableOfContentStyle Style { get; } #Gets the template style used to create this table of contents.
public String Text { get; set; } #Gets or sets the heading text displayed for the table of contents.
public String TextNoContent { get; set; } #Gets or sets the text shown when the document has no entries for the table of contents.
Template1 #Structured document tag implementing the default table-of-contents layout.
Template2 #Alternative layout used for table-of-contents generation.