Comments
Manage the cell comments of your online spreadsheets using the following methods.
Documentation
Section titled “Documentation”Methods
Section titled “Methods”Available methods for cell comments management.
| Method | Description |
|---|---|
| setComments | Add or remove comments from a spreadsheet cell. @param comments[].cellName - reference cell for comment. @param comments[].value - the comment. If the value of this property is an empty string, the current comment for that cell, if any, will be removed Jworksheet setComments(comments: { cellName: string; value: string | { comments: string; date: Date; userId?: number; name?: string; }[]; }[]): Promise<void> POST /api/:guid/:worksheetIndex/comments |
| getComments | Get the comments from a cell. @param cellNames - cells and/or comments whose comment should be returned. Jworksheet getComments(cellNames?: string): Promise<{ [cellName: string]: string | { comments: string; date: string; name?: string }[]; }>; GET /api/:guid/:worksheetIndex/comments/:cellNames |
Examples
Section titled “Examples”Set comments
Section titled “Set comments”Add a note to cell A1 and a comment to cell B3.
import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// New commentsconst comments = [ { cellName: "A1", value: "first comment" }, { cellName: "B3", value: [{ comments: "Something", date: new Date(), name: "Random name" }], },];
// Set new commentsworksheet .setComments(comments) .then(() => { // It worked correctly }) .catch((err) => { console.log(err); });curl -X POST "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/comments" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i" \ -H "Content-Type: application/json" \ -d '{ "comments": [ { "cellName": "A1", "value": "first comment" }, { "cellName": "B3", "value": [ { "comments": "Something", "date": "2025-05-07T00:00:00.000Z", "name": "Random name" } ] } ] }'Get comments from a cell
Section titled “Get comments from a cell”It is possible get the comments from multiple cells using comma or a range, such as D1:D4.
import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// Get comments from A1 - You can use D1:D4 or A1,A2,A3 for multiple cellsworksheet.getComments("A1").then((comments) => { console.log(comments);});curl -X GET "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/comments/A1" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"