Spreadsheet Comments

Adding comments in the spreadsheet cells is part of the JSS native methods. This section covers the related methods and events for interacting with the spreadsheet comments.



The following methods can be used to get or set comments in one or multiple cells.
getComments Get comments from a cell or from the whole table.
spreadsheet.getComments(cellName: String | null)
@Param mixed - cell identification or null for the whole table.
setComments Add comment to one or multiple cells.
spreadsheet.setComments(cellName: Mixed | Array, comments: String=)
@param {string|Object} - Identification of a cell or an array of objects with multiple comments
@param {string=} comments - Comments to be added to the cell


The onbeforecomments can be used to intercept, change or cancel the result of any comments applied by the user.
onbeforecommentsonbeforecomments(worksheet: Object, newValue: Array) : Array | null | false
The method should return an array with overwritten values, false to cancel the action or null to continue with the user action.
oncommentsoncomments(worksheet: Object, newValue: Array, oldValue: Array) : void

Initial Settings

The following properties are available through the initialization of the online spreadsheet.
allowComments: booleanEnable the user to enter new comments on cells.
comments: arrayArray with the initial comments.


The following example shows how to start the spreadsheet with a few initial comments and allow users to edit or insert new comments using the context menu.

Interact with the cell comments programmatically

To apply comments via JavaScript, you can use the methods setComments or getComments, as follow:

Source code

<script src="https://jspreadsheet.com/v9/jspreadsheet.js"></script>
<link rel="stylesheet" href="https://jspreadsheet.com/v9/jspreadsheet.css" type="text/css" />
<script src="https://jsuites.net/v4/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v4/jsuites.css" type="text/css" />

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />

<div id="spreadsheet"></div>

// Set your JSS license key (The following key only works for one day)

// Create the spreadsheet
var worksheets = jspreadsheet(document.getElementById('spreadsheet'), {
    worksheets: [
            data: [
                ['US', 'Cheese', '2019-02-12'],
                ['CA', 'Apples', '2019-03-01'],
                ['CA', 'Carrots', '2018-11-10'],
                ['BR', 'Oranges', '2019-01-12'],
            columns: [{
                width: '300px',
            allowComments: true,
            comments: {
                B1:'Initial comments on B1',
                C1:'Iniatial comments on C1'
    oncomments: function() {

<button type="button" onclick="worksheets[0].setComments('A1', 'Test');">
Set A1 comments

<button type="button" onclick="alert(worksheets[0].getComments('A1'));">
Get A1 comments

<button type="button" onclick="worksheets[0].setComments('A1', '');">
Reset A1 comments


Related content

Advanced comments extension

It is possible to create multiple comments in a cell with the user identification using the advance comments extension available in the Premium edition.

Click here to understand more about that.

Create applications with spreadsheet-like controls