Skip to main content

AddComment

Adds a comment to the current range.

Syntax

expression.AddComment(sText, sAuthor);

expression - A variable that represents a ApiRange class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sTextRequiredstringThe comment text.
sAuthorRequiredstringThe author's name (optional).

Returns

ApiComment | null

Example

This example adds a comment to the range.

var oWorksheet = Api.GetActiveSheet();
var oRange = oWorksheet.GetRange("A1");
oRange.SetValue("1");
oRange.AddComment("This is just a number.");
oWorksheet.GetRange("A3").SetValue("The comment was added to the cell A1.");
oWorksheet.GetRange("A4").SetValue("Comment: " + oRange.GetComment().GetText());