Edit

Share via


Excel.CommentChangedEventArgs interface

Occurs when existing comments are changed.

Remarks

[ API set: ExcelApi 1.12 ]

Examples

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

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

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

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

Properties

changeType

Gets the change type that represents how the changed event is triggered.

commentDetails

Get the CommentDetail array which contains the comment ID and IDs of its related replies.

source

Specifies the source of the event. See Excel.EventSource for details.

type

Gets the type of the event. See Excel.EventType for details.

worksheetId

Gets the ID of the worksheet in which the event happened.

Property Details

changeType

Gets the change type that represents how the changed event is triggered.

changeType: Excel.CommentChangeType | "CommentEdited" | "CommentResolved" | "CommentReopened" | "ReplyAdded" | "ReplyDeleted" | "ReplyEdited";

Property Value

Excel.CommentChangeType | "CommentEdited" | "CommentResolved" | "CommentReopened" | "ReplyAdded" | "ReplyDeleted" | "ReplyEdited"

Remarks

[ API set: ExcelApi 1.12 ]

commentDetails

Get the CommentDetail array which contains the comment ID and IDs of its related replies.

commentDetails: Excel.CommentDetail[];

Property Value

Remarks

[ API set: ExcelApi 1.12 ]

source

Specifies the source of the event. See Excel.EventSource for details.

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

Property Value

Excel.EventSource | "Local" | "Remote"

Remarks

[ API set: ExcelApi 1.12 ]

type

Gets the type of the event. See Excel.EventType for details.

type: "CommentChanged";

Property Value

"CommentChanged"

Remarks

[ API set: ExcelApi 1.12 ]

worksheetId

Gets the ID of the worksheet in which the event happened.

worksheetId: string;

Property Value

string

Remarks

[ API set: ExcelApi 1.12 ]