Skip to content
Mog is in active development. The GitHub repo, SDK packages, and community channels are not yet available. Follow for launch updates

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>;
ParameterTypeRequired
addressstringrequired
textstringrequired
authorstringoptional

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>;
ParameterTypeRequired
addressstringrequired

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>;
ParameterTypeRequired
addressstringrequired

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>;
ParameterTypeRequired
indexnumberrequired

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>;
ParameterTypeRequired
addressstringrequired
visiblebooleanrequired

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>;
ParameterTypeRequired
addressstringrequired
heightnumberrequired

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>;
ParameterTypeRequired
addressstringrequired
widthnumberrequired

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>;
ParameterTypeRequired
addressstringrequired
textstringrequired
authorstringrequired

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>;
ParameterTypeRequired
commentIdstringrequired
textstringrequired

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>;
ParameterTypeRequired
commentIdstringrequired
contentstringrequired
mentionsCommentMention[]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>;
ParameterTypeRequired
commentIdstringrequired

Delete a comment. @param commentId - Comment identifier

resolveThread

Promise<void>
resolveThread(threadId: string, resolved: boolean): Promise<void>;
ParameterTypeRequired
threadIdstringrequired
resolvedbooleanrequired

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[]>;
ParameterTypeRequired
addressstringrequired

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>;
ParameterTypeRequired
commentIdstringrequired
textstringrequired
authorstringrequired

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[]>;
ParameterTypeRequired
commentIdstringrequired

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>;
ParameterTypeRequired
commentIdstringrequired

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>;
ParameterTypeRequired
commentIdstringrequired

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>;
ParameterTypeRequired
replyIdstringrequired

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>;
ParameterTypeRequired
commentIdstringrequired

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>;
ParameterTypeRequired
commentIdstringrequired
indexnumberrequired

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>;
ParameterTypeRequired
addressstringrequired

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>;
ParameterTypeRequired
addressstringrequired

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>;
ParameterTypeRequired
addressstringrequired

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