Excel.CommentReplyCollection class

Represents a collection of comment reply objects that are part of the comment.

Extends

Remarks

[ API set: ExcelApi 1.10 ]

Properties

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

items

Gets the loaded child items in this collection.

Methods

add(content, contentType)

Creates a comment reply for a comment.

add(content, contentTypeString)

Creates a comment reply for a comment.

getCount()

Gets the number of comment replies in the collection.

getItem(commentReplyId)

Returns a comment reply identified by its ID.

getItemAt(index)

Gets a comment reply based on its position in the collection.

getItemOrNullObject(commentReplyId)

Returns a comment reply identified by its ID. If the comment reply object does not exist, then this method returns an object with its isNullObject property set to true. For further information, see *OrNullObject methods and properties.

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.CommentReplyCollection object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.CommentReplyCollectionData) that contains an "items" array with shallow copies of any loaded properties from the collection's items.

Property Details

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

items

Gets the loaded child items in this collection.

readonly items: Excel.CommentReply[];

Property Value

Method Details

add(content, contentType)

Creates a comment reply for a comment.

add(content: CommentRichContent | string, contentType?: Excel.ContentType): Excel.CommentReply;

Parameters

content

Excel.CommentRichContent | string

The comment's content. This can be either a string or a CommentRichContent object (e.g., for comments with mentions). [Api set: ExcelApi 1.10 for string, 1.11 for CommentRichContent object]

contentType
Excel.ContentType

Optional. The type of content contained within the comment. The default value is enum ContentType.Plain. [Api set: ExcelApi 1.10 for Enum ContentType.Plain, 1.11 for Enum ContentType.Mention]

Returns

Remarks

[ API set: ExcelApi 1.10 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comment/comment-replies.yaml

await Excel.run(async (context) => {
    // Adds a reply to the first comment in this worksheet.
    const sheet = context.workbook.worksheets.getItem("Comments");
    const comment = sheet.comments.getItemAt(0);
    comment.replies.add("Add content to this worksheet.");
    await context.sync();
});

add(content, contentTypeString)

Creates a comment reply for a comment.

add(content: CommentRichContent | string, contentTypeString?: "Plain" | "Mention"): Excel.CommentReply;

Parameters

content

Excel.CommentRichContent | string

The comment's content. This can be either a string or a CommentRichContent object (e.g., for comments with mentions). [Api set: ExcelApi 1.10 for string, 1.11 for CommentRichContent object]

contentTypeString

"Plain" | "Mention"

Optional. The type of content contained within the comment. The default value is enum ContentType.Plain. [Api set: ExcelApi 1.10 for Enum ContentType.Plain, 1.11 for Enum ContentType.Mention]

Returns

Remarks

[ API set: ExcelApi 1.10 ]

getCount()

Gets the number of comment replies in the collection.

getCount(): OfficeExtension.ClientResult<number>;

Returns

Remarks

[ API set: ExcelApi 1.10 ]

getItem(commentReplyId)

Returns a comment reply identified by its ID.

getItem(commentReplyId: string): Excel.CommentReply;

Parameters

commentReplyId

string

The identifier for the comment reply.

Returns

Remarks

[ API set: ExcelApi 1.10 ]

getItemAt(index)

Gets a comment reply based on its position in the collection.

getItemAt(index: number): Excel.CommentReply;

Parameters

index

number

The index value of the comment reply to be retrieved. The collection uses zero-based indexing.

Returns

Remarks

[ API set: ExcelApi 1.10 ]

getItemOrNullObject(commentReplyId)

Returns a comment reply identified by its ID. If the comment reply object does not exist, then this method returns an object with its isNullObject property set to true. For further information, see *OrNullObject methods and properties.

getItemOrNullObject(commentReplyId: string): Excel.CommentReply;

Parameters

commentReplyId

string

The identifier for the comment reply.

Returns

Remarks

[ API set: ExcelApi 1.14 ]

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(options?: Excel.Interfaces.CommentReplyCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.CommentReplyCollection;

Parameters

options

Excel.Interfaces.CommentReplyCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions

Provides options for which properties of the object to load.

Returns

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): Excel.CommentReplyCollection;

Parameters

propertyNames

string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: OfficeExtension.LoadOption): Excel.CommentReplyCollection;

Parameters

propertyNamesAndPaths
OfficeExtension.LoadOption

propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.CommentReplyCollection object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.CommentReplyCollectionData) that contains an "items" array with shallow copies of any loaded properties from the collection's items.

toJSON(): Excel.Interfaces.CommentReplyCollectionData;

Returns