Skip to content

Comments

Manage the cell comments of your online spreadsheets using the following methods.

Available methods for cell comments management.

MethodDescription
setCommentsAdd 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

Jspreadsheet setComments(comments: { cellName: string; value: string }[]): Promise<void>

POST /api/:guid/comments
getCommentsGet the comments from a cell.
@param cellNames - cells and/or comments whose comment should be returned.

Jspreadsheet getComments(cellNames?: string): Promise<{ [cellName: string]: string }>

GET /api/:guid/comments

Add comments to a spreadsheet cell.

import { Client } from "@intrasheets/client";
// Create a new client
const client = new Client({
// API Server
baseUrl: "http://localhost:8009/api",
// Your authentication token
token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});
// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Comments
const comments = [
{
cellName: "A1",
value: "comments",
},
{
cellName: "B2",
value: "comments B2",
},
]
// Update comments
spreadsheet.setComments(comments).then(() => {
// It worked correctly
}).catch((err) => {
console.log(err);
});

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 client
const client = new Client({
// API Server
baseUrl: "http://localhost:8009/api",
// Your authentication token
token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",
});
// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Get comments from A1 - You can use D1:D4 or A1,A2,A3 for multiple cells
spreadsheet.getComments("A1").then((comments) => {
console.log(comments);
});