Excel.CommentAddedEventArgs interface
提供有关引发注释添加事件的注释的信息。
注解
示例
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}`);
});
}
属性
| comment |
|
| source | 指定时间源。 有关详细信息,请参阅 |
| type | 获取事件的类型。 有关详细信息,请参阅 |
| worksheet |
获取发生事件的工作表的 ID。 |
属性详细信息
commentDetails
CommentDetail获取包含其相关答复的注释 ID 和 ID 的数组。
commentDetails: Excel.CommentDetail[];
属性值
注解
source
指定时间源。 有关详细信息,请参阅 Excel.EventSource。
source: Excel.EventSource | "Local" | "Remote";
属性值
Excel.EventSource | "Local" | "Remote"
注解
type
获取事件的类型。 有关详细信息,请参阅 Excel.EventType。
type: "CommentAdded";
属性值
"CommentAdded"