> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/spreadsheet-editor/manage-cell-comments.md).

# Manage cell comments in Spreadsheet Editor

Learn how to add, reply to, edit, resolve, and delete cell comments in Apryse Spreadsheet Editor using the CommentManager API. Includes code examples.

{% hint style="info" %}
**Requirements**

These packages are required to use these features in production. Trial keys have unlimited access to all features.

<a href="/web/get-started/readme.md" class="button primary">Web SDK</a><a href="https://apryse.com/capabilities#SpreadsheetEditor" class="button primary">Package: Spreadsheet Editor</a><a href="https://showcase.apryse.com/spreadsheet-editor" class="button primary">Live demo</a>
{% endhint %}

Spreadsheet Editor lets users add comments and threaded replies to specific spreadsheet cells. You can then collaborate with comments by asking questions, flagging issues, and replying right where the work is happening. This is useful when reviewing reports, checking calculations, or working on a forecast across teams.

Legacy notes are supported but are converted to the comment threads upon load. Saving will not retain legacy notes since they have already been converted.

<div align="left"><figure><img src="https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2FXKF3dNHxC6qEIwhVHYgL%2FScreenshot%202026-09-30%20at%209.48.25%E2%80%AFAM.png?alt=media&amp;token=17a7fb09-46ec-4d36-96c8-69ac0d9509a6" alt="Comment thread on cell R4 of the Invoice sheet in Spreadsheet Editor, showing a question, threaded replies, and a &#x22;Resolved set by Janice&#x22; entry, with an &#x22;Add reply&#x22; box at the bottom."><figcaption><p>A resolved comment thread with replies on a spreadsheet cell.</p></figcaption></figure></div>

## Manage comments via API

This section covers the APIs for working with cell comments and replies. You create, change, and delete comments through the `CommentManager` class. Each comment is returned as a read-only `SpreadsheetComment` object.

### Get the comment manager

Use the [SpreadsheetEditorManager.getCommentManager](https://sdk.apryse.com/api/web/Core.SpreadsheetEditor.SpreadsheetEditorManager.html#getCommentManager__anchor) API to get the comment manager. The [CommentManager](https://sdk.apryse.com/api/web/Core.SpreadsheetEditor.CommentManager.html) class contains all APIs needed to get, create, edit, resolve, and delete comments and replies. The following code sample gets the comment manager once the editor is ready.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
WebViewer(...)
  .then(instance => {
    const { documentViewer, SpreadsheetEditor } = instance.Core;
    const spreadsheetEditorManager = documentViewer.getSpreadsheetEditorManager();
    const SpreadsheetEditorEvents = SpreadsheetEditor.SpreadsheetEditorManager.Events;

    spreadsheetEditorManager.addEventListener(SpreadsheetEditorEvents.SPREADSHEET_EDITOR_READY, () => {
      const commentManager = spreadsheetEditorManager.getCommentManager();
      console.log(commentManager);
    });
  });
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Get comments

Use the [`CommentManager.getComments`](https://sdk.apryse.com/api/web/Core.SpreadsheetEditor.CommentManager.html#getComments__anchor) API to retrieve all comments in a workbook. Each comment is a read-only [SpreadsheetComment](https://sdk.apryse.com/api/web/Core.SpreadsheetEditor.SpreadsheetComment.html) object that contains the comment's message, cell address, state, author, and replies. The following code sample counts the comments in the workbook and logs the details of the first one.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
WebViewer(...)
  .then(instance => {
    const { documentViewer, SpreadsheetEditor } = instance.Core;
    const spreadsheetEditorManager = documentViewer.getSpreadsheetEditorManager();
    const SpreadsheetEditorEvents = SpreadsheetEditor.SpreadsheetEditorManager.Events;

    spreadsheetEditorManager.addEventListener(SpreadsheetEditorEvents.SPREADSHEET_EDITOR_READY, () => {
      const commentManager = spreadsheetEditorManager.getCommentManager();
      const comments = commentManager.getComments();
      console.log(`Found ${comments.length} comment(s)`);
      
      const comment = comments[0];
      if (comment) {
        console.log(comment);
        console.log(comment.getId());
        console.log(comment.getMessage());
        console.log(comment.getCellAddress());
        console.log(comment.getState());
        console.log(comment.getReplies());
      }
    });
  });
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Add comments or replies

{% hint style="info" %}
**Info:** Edit mode must be enabled.
{% endhint %}

Use the [`CommentManager.addComment`](https://sdk.apryse.com/api/web/Core.SpreadsheetEditor.CommentManager.html#addComment__anchor) or [`CommentManager.addReply`](https://sdk.apryse.com/api/web/Core.SpreadsheetEditor.CommentManager.html#addReply__anchor) APIs to create a new comment or reply, respectively.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
WebViewer(...)
  .then(instance => {
    const { documentViewer, SpreadsheetEditor } = instance.Core;
    const spreadsheetEditorManager = documentViewer.getSpreadsheetEditorManager();
    const SpreadsheetEditorEvents = SpreadsheetEditor.SpreadsheetEditorManager.Events;

    spreadsheetEditorManager.addEventListener(SpreadsheetEditorEvents.SPREADSHEET_EDITOR_READY, () => {
      const commentManager = spreadsheetEditorManager.getCommentManager();
      const author = 'Guest';

      // Add a comment to cell A1.
      const comment = commentManager.addComment('This is a comment.', {
        sheetName: 'Sheet1',
        cellString: 'A1',
        author: author,
      });

      // Add a reply to the newly created comment.
      const replyMessage = 'LGTM!';
      const replyAuthor = 'Reviewer';
      commentManager.addReply(comment.getId(), replyMessage, replyAuthor);
    });
  });
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Edit comments or replies

{% hint style="info" %}
**Info:** Edit mode must be enabled.
{% endhint %}

Use the [`CommentManager.setCommentMessage`](https://sdk.apryse.com/api/web/Core.SpreadsheetEditor.CommentManager.html#setCommentMessage__anchor) API to update a comment or reply message.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
WebViewer(...)
  .then(instance => {
    const { documentViewer, SpreadsheetEditor } = instance.Core;
    const spreadsheetEditorManager = documentViewer.getSpreadsheetEditorManager();
    const SpreadsheetEditorEvents = SpreadsheetEditor.SpreadsheetEditorManager.Events;

    spreadsheetEditorManager.addEventListener(SpreadsheetEditorEvents.SPREADSHEET_EDITOR_READY, () => {
      const commentManager = spreadsheetEditorManager.getCommentManager();
      const comment = commentManager.getComments()[0];
      if (comment) {
        const updatedComment = commentManager.setCommentMessage(comment.getId(), 'Updated comment text.');
        console.log(updatedComment.getMessage());
      }
    });
  });
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Resolve comments

{% hint style="info" %}
**Info:** Edit mode must be enabled.
{% endhint %}

Use the [`CommentManager.setCommentState`](https://sdk.apryse.com/api/web/Core.SpreadsheetEditor.CommentManager.html#setCommentState__anchor) API to resolve or re-open comment threads. Available options are under the [SpreadsheetCommentState](https://sdk.apryse.com/api/web/Core.SpreadsheetEditor.html#.SpreadsheetCommentState__anchor) enum.

Adding replies or editing a resolved comment will automatically change the state back to `OPEN`.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
WebViewer(...)
  .then(instance => {
    const { documentViewer, SpreadsheetEditor } = instance.Core;
    const spreadsheetEditorManager = documentViewer.getSpreadsheetEditorManager();
    const SpreadsheetEditorEvents = SpreadsheetEditor.SpreadsheetEditorManager.Events;

    spreadsheetEditorManager.addEventListener(SpreadsheetEditorEvents.SPREADSHEET_EDITOR_READY, () => {
      const commentManager = spreadsheetEditorManager.getCommentManager();
      const comment = commentManager.getComments()[0];
      if (comment) {
        commentManager.setCommentState(
          comment.getId(),
          SpreadsheetEditor.SpreadsheetCommentState.RESOLVED
        );
      }
    });
  });
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Delete comments or replies

{% hint style="info" %}
**Info:** Edit mode must be enabled.
{% endhint %}

Use the [`CommentManager.deleteComment`](https://sdk.apryse.com/api/web/Core.SpreadsheetEditor.CommentManager.html#deleteComment__anchor) API to delete a comment or reply. Deleting a comment will also delete its replies. Deleting a reply will not delete its parent comment or sibling replies. The following code sample deletes the first comment in the workbook.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
WebViewer(...)
  .then(instance => {
    const { documentViewer, SpreadsheetEditor } = instance.Core;
    const spreadsheetEditorManager = documentViewer.getSpreadsheetEditorManager();
    const SpreadsheetEditorEvents = SpreadsheetEditor.SpreadsheetEditorManager.Events;

    spreadsheetEditorManager.addEventListener(SpreadsheetEditorEvents.SPREADSHEET_EDITOR_READY, () => {
      const commentManager = spreadsheetEditorManager.getCommentManager();
      const comment = commentManager.getComments()[0];
      if (comment) {
        commentManager.deleteComment(comment.getId());
      }
    });
  });
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/web/spreadsheet-editor/manage-cell-comments.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
