Excel.CommentAddedEventArgs interface
Provides information about the comments that raised the comment added event.
Remarks
Examples
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}`);
});
}
Properties
| comment |
Gets the |
| source | Specifies the source of the event. See |
| type | Gets the type of the event. See |
| worksheet |
Gets the ID of the worksheet in which the event happened. |
Property Details
commentDetails
Gets the CommentDetail array that contains the comment ID and IDs of its related replies.
commentDetails: Excel.CommentDetail[];
Property Value
Remarks
source
Specifies the source of the event. See Excel.EventSource for details.
source: Excel.EventSource | "Local" | "Remote";
Property Value
Excel.EventSource | "Local" | "Remote"
Remarks
type
Gets the type of the event. See Excel.EventType for details.
type: "CommentAdded";
Property Value
"CommentAdded"
Remarks
worksheetId
Gets the ID of the worksheet in which the event happened.
worksheetId: string;
Property Value
string