ws.comments
WorksheetComments
Sub-API for comment and note operations on a worksheet.
29 methods
addNote
→ Promise<void>addNote(address: string, text: string, author?: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| address | string | required |
| text | string | required |
| author | string | optional |
Add a note to a cell. @param address - A1-style cell address (e.g. "A1") @param text - Note text @param author - Optional author name (defaults to 'api')
getNote
→ Promise<Note | null>getNote(address: string): Promise<Note | null>;| Parameter | Type | Required |
|---|---|---|
| address | string | required |
Get the note for a cell as a Note object. @param address - A1-style cell address @returns The Note object, or null if no note
removeNote
→ Promise<void>removeNote(address: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| address | string | required |
Remove the note from a cell. @param address - A1-style cell address
count
→ Promise<number>count(): Promise<number>;Get the number of comments in the worksheet. @returns The total comment count
noteCount
→ Promise<number>noteCount(): Promise<number>;Get the number of notes (legacy comments) in the worksheet. @returns The count of notes only (excludes threaded comments)
listNotes
→ Promise<Note[]>listNotes(): Promise<Note[]>;List all notes (legacy comments) in the worksheet. @returns Array of notes
getNoteAt
→ Promise<Note | null>getNoteAt(index: number): Promise<Note | null>;| Parameter | Type | Required |
|---|---|---|
| index | number | required |
Get a note by index from the list of all notes. @param index - Zero-based index into the notes list @returns The Note at that index, or null if out of range
setNoteVisible
→ Promise<void>setNoteVisible(address: string, visible: boolean): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| address | string | required |
| visible | boolean | required |
Set the visibility of a note at the given cell address. @param address - A1-style cell address @param visible - Whether the note should be visible
setNoteHeight
→ Promise<void>setNoteHeight(address: string, height: number): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| address | string | required |
| height | number | required |
Set the height of a note callout box in points. @param address - A1-style cell address @param height - Height in points
setNoteWidth
→ Promise<void>setNoteWidth(address: string, width: number): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| address | string | required |
| width | number | required |
Set the width of a note callout box in points. @param address - A1-style cell address @param width - Width in points
add
→ Promise<Comment>add(address: string, text: string, author: string): Promise<Comment>;| Parameter | Type | Required |
|---|---|---|
| address | string | required |
| text | string | required |
| author | string | required |
Add a threaded comment to a cell. @param address - A1-style cell address @param text - Comment text @param author - Author name or identifier
update
→ Promise<void>update(commentId: string, text: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| commentId | string | required |
| text | string | required |
Update an existing comment's text. @param commentId - Comment identifier @param text - New comment text
updateMentions
→ Promise<void>updateMentions(
commentId: string,
content: string,
mentions: CommentMention[],
): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| commentId | string | required |
| content | string | required |
| mentions | CommentMention[] | required |
Update a comment with mention content (OfficeJS updateMentions equivalent). Sets content, content_type to Mention, and mentions array in a single mutation. @param commentId - Comment identifier @param content - Full comment text including mention display text @param mentions - Array of mention objects describing @mentions within the text
delete
→ Promise<void>delete(commentId: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| commentId | string | required |
Delete a comment. @param commentId - Comment identifier
resolveThread
→ Promise<void>resolveThread(threadId: string, resolved: boolean): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| threadId | string | required |
| resolved | boolean | required |
Set the resolved state of a comment thread. @param threadId - Thread identifier (cell ID) @param resolved - Whether the thread should be marked as resolved
list
→ Promise<Comment[]>list(): Promise<Comment[]>;List all comments in the worksheet. @returns Array of all comments
getForCell
→ Promise<Comment[]>getForCell(address: string): Promise<Comment[]>;| Parameter | Type | Required |
|---|---|---|
| address | string | required |
Get all comments for a specific cell. @param address - A1-style cell address @returns Array of comments for the cell
addReply
→ Promise<Comment>addReply(commentId: string, text: string, author: string): Promise<Comment>;| Parameter | Type | Required |
|---|---|---|
| commentId | string | required |
| text | string | required |
| author | string | required |
Add a reply to an existing comment. @param commentId - ID of the comment to reply to @param text - Reply text @param author - Author name or identifier @returns The created reply comment
getThread
→ Promise<Comment[]>getThread(commentId: string): Promise<Comment[]>;| Parameter | Type | Required |
|---|---|---|
| commentId | string | required |
Get all comments in a thread (root + replies), sorted by createdAt. @param commentId - ID of any comment in the thread @returns Array of comments in the thread
getById
→ Promise<Comment | null>getById(commentId: string): Promise<Comment | null>;| Parameter | Type | Required |
|---|---|---|
| commentId | string | required |
Get a single comment by its ID. @param commentId - Comment identifier @returns The comment, or null if not found
getLocation
→ Promise<string | null>getLocation(commentId: string): Promise<string | null>;| Parameter | Type | Required |
|---|---|---|
| commentId | string | required |
Get the A1-style cell address for a comment. Resolves the comment's internal cell reference (CellId) to a human-readable address like "A1", "B3", etc. @param commentId - Comment identifier @returns The A1-style cell address, or null if the comment doesn't exist
getParentByReplyId
→ Promise<Comment | null>getParentByReplyId(replyId: string): Promise<Comment | null>;| Parameter | Type | Required |
|---|---|---|
| replyId | string | required |
Get the parent comment for a reply. @param replyId - ID of the reply comment @returns The parent comment, or null if not found or not a reply
getReplyCount
→ Promise<number>getReplyCount(commentId: string): Promise<number>;| Parameter | Type | Required |
|---|---|---|
| commentId | string | required |
Get the number of replies in a thread (excluding the root comment). @param commentId - ID of any comment in the thread @returns The reply count
getReplyAt
→ Promise<Comment | null>getReplyAt(commentId: string, index: number): Promise<Comment | null>;| Parameter | Type | Required |
|---|---|---|
| commentId | string | required |
| index | number | required |
Get a reply at a specific index within a thread (zero-based, excludes root). @param commentId - ID of any comment in the thread @param index - Zero-based index into the replies @returns The reply comment, or null if out of range
getNoteLocation
→ Promise<string | null>getNoteLocation(address: string): Promise<string | null>;| Parameter | Type | Required |
|---|---|---|
| address | string | required |
Get the A1-style cell address for a note. @param address - A1-style cell address @returns The A1-style cell address, or null if no note exists at that address
hasComment
→ Promise<boolean>hasComment(address: string): Promise<boolean>;| Parameter | Type | Required |
|---|---|---|
| address | string | required |
Check if a cell has any comments. @param address - A1-style cell address @returns True if the cell has at least one comment
deleteForCell
→ Promise<number>deleteForCell(address: string): Promise<number>;| Parameter | Type | Required |
|---|---|---|
| address | string | required |
Delete all comments on a cell. @param address - A1-style cell address @returns The number of comments deleted
clear
→ Promise<void>clear(): Promise<void>;Clear all comments on the worksheet.
clean
→ Promise<number>clean(): Promise<number>;Remove orphaned comments (comments referencing non-existent cells). @returns The number of orphaned comments removed