API Reference
WordTableOfContent
Represents a table of contents within a Word document.
Inheritance
- WordElement
- WordTableOfContent
Usage
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by
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 WordCaptionListRefreshReport RefreshCaptionList(String sequenceIdentifier, String title = null) #WordCaptionListRefreshReportRegenerates visible list entries from generated caption paragraphs that contain a matching SEQ field.
Parameters
- sequenceIdentifier System.String
- Caption sequence identifier, for example Figure or Table.
- title System.String = null
- Optional title shown above the generated list.
Returns
A report describing the generated caption-list entries.
public WordTableOfContentRefreshReport RefreshEntries() #WordTableOfContentRefreshReportRegenerates visible table-of-contents entries from body heading paragraphs.
Returns
A report describing the generated entries and skipped headings.
public WordIndexRefreshReport RefreshIndex(String title = null) #WordIndexRefreshReportRegenerates visible index entries from XE fields that OfficeIMO can evaluate deterministically.
Parameters
- title System.String = null
- Optional title shown above the generated index.
Returns
A report describing the generated index entries.
public WordIndexRefreshReport RefreshIndex(String title, String entryType) #WordIndexRefreshReportRegenerates visible index entries from XE fields matching the requested entry type.
Parameters
- title System.String
- Optional title shown above the generated index.
- entryType System.String
- Optional Word index entry type from XE \f switches. Pass null to include all entry types.
Returns
A report describing the generated index entries.
public WordIndexRefreshReport RefreshIndex(String title, String entryType, String bookmarkName) #WordIndexRefreshReportRegenerates visible index entries from body XE fields matching the requested entry type and bookmark scope.
Parameters
- title System.String
- Optional title shown above the generated index.
- entryType System.String
- Optional Word index entry type from XE \f switches. Pass null to include all entry types.
- bookmarkName System.String
- Optional Word bookmark name from an INDEX \b switch. Pass null to scan the whole body.
Returns
A report describing the generated index entries.
public WordCaptionListRefreshReport RefreshListOfFigures() #WordCaptionListRefreshReportRegenerates a generated list of figures from caption paragraphs that contain SEQ Figure fields.
Returns
A report describing the generated figure-list entries.
public WordCaptionListRefreshReport RefreshListOfTables() #WordCaptionListRefreshReportRegenerates a generated list of tables from caption paragraphs that contain SEQ Table fields.
Returns
A report describing the generated table-list entries.
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
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 Int32 MinLevel { get; } #Gets the minimum heading level included by the TOC field switch.
public Int32 MaxLevel { get; } #Gets the maximum heading level included by the TOC field switch.
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.