Word.TableOfContentsMarkEntryOptions interface

指定插入目录 条目 (TC) 字段的选项。

注解

API 集:WordApiDesktop 1.4

使用方

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/42-reference-tables/table-of-figures.yaml

// Marks each figure paragraph as a table entry.
await Word.run(async (context) => {
    const documentBody: Word.Body = context.document.body;
    const tablesOfFigures: Word.TableOfFiguresCollection = context.document.tablesOfFigures;
    const paragraphs: Word.ParagraphCollection = documentBody.paragraphs;
    paragraphs.load("items/text");
    await context.sync();

    const figureParagraphs: Word.Paragraph[] = paragraphs.items.filter((paragraph: Word.Paragraph) =>
        paragraph.text.startsWith("Figure ")
    );
    figureParagraphs.forEach((figureParagraph: Word.Paragraph) => {
        const entryOptions: Word.TableOfContentsMarkEntryOptions = {
            entry: figureParagraph.text,
            level: 1,
            tableId: "F",
        };
        const entryRange: Word.Range = figureParagraph.getRange();
        tablesOfFigures.markTocEntry(entryRange, entryOptions);
    });
    await context.sync();

    console.log(`Marked ${figureParagraphs.length} table of figures entries.`);
});

属性

entry

如果提供,则指定在目录或图表中显示的文本。 要指示子条目,请包括主条目文本和子条目文本,用冒号 (“:”) (分隔,例如,“Introduction:The Product”) 。 设置此 entryAutoText 属性时,将忽略此属性。

entryAutoText

如果提供,则指定包含图表或目录文本的自动图文集条目名称。 使用此属性时,将忽略该 entry 属性。

level

如果提供,则指定目录或图表中条目的级别,值应为 1 到 9。

tableId

如果提供,则为目录或图表指定一个字母标识符 (例如,“i”表示“插图”) 。

属性详细信息

entry

如果提供,则指定在目录或图表中显示的文本。 要指示子条目,请包括主条目文本和子条目文本,用冒号 (“:”) (分隔,例如,“Introduction:The Product”) 。 设置此 entryAutoText 属性时,将忽略此属性。

entry?: string;

属性值

string

注解

API 集:WordApiDesktop 1.4

entryAutoText

如果提供,则指定包含图表或目录文本的自动图文集条目名称。 使用此属性时,将忽略该 entry 属性。

entryAutoText?: string;

属性值

string

注解

API 集:WordApiDesktop 1.4

level

如果提供,则指定目录或图表中条目的级别,值应为 1 到 9。

level?: number;

属性值

number

注解

API 集:WordApiDesktop 1.4

tableId

如果提供,则为目录或图表指定一个字母标识符 (例如,“i”表示“插图”) 。

tableId?: string;

属性值

string

注解

API 集:WordApiDesktop 1.4