通过


Excel.CommentAddedEventArgs interface

提供有关引发注释添加事件的注释的信息。

注解

[ API 集:ExcelApi 1.12 ]

示例

async function registerEventHandler() {
    await Excel.run(async (context) => {
        // Register the onAdded comment event handler.
        const comments = context.workbook.worksheets.getActiveWorksheet().comments;
        comments.onAdded.add(commentAdded);
        await context.sync();
    });
}

async function commentAdded(event: Excel.CommentAddedEventArgs) {
    // Retrieve the added comment using the comment ID.
    // Note: This function assumes only a single comment is added at a time.
    await Excel.run(async (context) => {
        const addedComment = context.workbook.comments.getItem(event.commentDetails[0].commentId);

        // Load the added comment's data.
        addedComment.load(["content", "authorName", "creationDate"]);
        await context.sync();

        // Print out the added comment's data.
        console.log(`A comment was added:`);
        console.log(`    ID: ${event.commentDetails[0].commentId}`);
        console.log(`    Comment content: ${addedComment.content}`);
        console.log(`    Comment author: ${addedComment.authorName}`);
        console.log(`    Creation date: ${addedComment.creationDate}`);
    });
}

属性

commentDetails

CommentDetail获取包含其相关答复的注释 ID 和 ID 的数组。

source

指定时间源。 有关详细信息,请参阅 Excel.EventSource

type

获取事件的类型。 有关详细信息,请参阅 Excel.EventType

worksheetId

获取发生事件的工作表的 ID。

属性详细信息

commentDetails

CommentDetail获取包含其相关答复的注释 ID 和 ID 的数组。

commentDetails: Excel.CommentDetail[];

属性值

注解

[ API 集:ExcelApi 1.12 ]

source

指定时间源。 有关详细信息,请参阅 Excel.EventSource

source: Excel.EventSource | "Local" | "Remote";

属性值

Excel.EventSource | "Local" | "Remote"

注解

[ API 集:ExcelApi 1.12 ]

type

获取事件的类型。 有关详细信息,请参阅 Excel.EventType

type: "CommentAdded";

属性值

"CommentAdded"

注解

[ API 集:ExcelApi 1.12 ]

worksheetId

获取发生事件的工作表的 ID。

worksheetId: string;

属性值

string

注解

[ API 集:ExcelApi 1.12 ]