OfficeIMO

API Reference

Class

WordTableOfContent

Namespace OfficeIMO.Word
Assembly OfficeIMO.Word

Represents a table of contents within a Word document.

Inheritance

Constructors

WordTableOfContent 2 overloads
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 requiredposition: 0
Parent document where the table of contents will be created.
tableOfContentStyle OfficeIMO.Word.TableOfContentStyle requiredposition: 1
Template style used to generate the table of contents.
minLevel System.Int32 = 1 optionalposition: 2
Minimum heading level to include (1..9).
maxLevel System.Int32 = 3 optionalposition: 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 requiredposition: 0
Parent document that owns the table of contents.
sdtBlock DocumentFormat.OpenXml.Wordprocessing.SdtBlock requiredposition: 1
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 required
Document that will own the structured document tag.
style OfficeIMO.Word.TableOfContentStyle required
Template identifier to retrieve.
public WordTableOfContent Regenerate() #
Returns: WordTableOfContent

Removes this table of contents and creates a new one in the same location.

Returns

The newly created WordTableOfContent instance.

public Void Remove() #
Returns: Void

Deletes this table of contents from the parent document.

public Void SetLevels(Int32 minLevel, Int32 maxLevel) #
Returns: Void

Updates the heading levels included by the TOC field switch (for example: \o "1-5").

Parameters

minLevel System.Int32 requiredposition: 0
Minimum heading level to include (1..9).
maxLevel System.Int32 requiredposition: 1
Maximum heading level to include (1..9).
public Void Update() #
Returns: Void

Flags the document to update this table of contents when the file is opened.

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.