Products

Spreadsheet comments

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

Documentation

Methods

Available methods for cell comments management.
MethodDescription
setComments Add or remove comments from a spreadsheet cell.
setComments(comments: { cellName: string; value: string }[]): Promise<void>
@param comments[].cellName - reference cell for comment.
@param comments[].value - the comment.

POST /api/:guid/comments
getComments Get the comments from a cell.
getComments(cellNames?: string): Promise<{ [cellName: string]: string }>
@param cellNames - cells and/or comments whose comment should be returned.

GET /api/:guid/comments


Examples

Add comments


NodeJS
PHP
import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';

// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Create a new client
const client = new Client(token);

// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);

// Update comments
spreadsheet.setComment([
    {
        cellName: "A1",
        value: "comments",
    },
    {
        cellName: "B2",
        value: "comments B2",
    },
]).then(() => {
    // It worked correctly
}).catch((err) => {
    console.log(err);
});
<?php
require 'vendor/autoload.php';

use jspreadsheet\Jspreadsheet;

// Access token
$token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';

// Spreadsheet Guid
$guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Create a new client
$client = new Jspreadsheet($token);

// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);

// Update
$result = $spreadsheet->getCells()->setComments([
    'A1' => 'comments',
    'B2' => 'comments B2'
]);

// Result
print_r($result);

// { "success": 1, "message": "Updated" }

Read comments

Get all comments from a cell on your spreadsheet

It is possible get the comments from multiple cells using comma or a range, such as D1:D4.

NodeJS
PHP
import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';

// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Create a new client
const client = new Client(token);

// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);

// Get comments from A1
spreadsheet.getComment("A1") // D1:D4 or A1,A2,A3 for multiple cells
    .then((comments) => {
        console.log(comments);
    });

// {
//     "A1": "comments"
// }
<?php
require 'vendor/autoload.php';

use jspreadsheet\Jspreadsheet;

// Access token
$token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';

// Spreadsheet Guid
$guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';

// Create a new client
$client = new Jspreadsheet($token);

// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);

// Get comments from A1
$result = $spreadsheet->getCells('A1')->getComments(); // ['A1','A2','C3'] or D1:D4 or A1,A2,A3 for multiple cells

print_r($result);

// {"A1": "comments"}