Skip to main content

AddComment

Adds a comment to all contents of the current table. 💡 Please note that this table must be in the document.

Syntax

expression.AddComment(sText, sAuthor, sUserId);

expression - A variable that represents a ApiTable class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sTextRequiredstringThe comment text (required).
sAuthorRequiredstringThe author's name (optional).
sUserIdRequiredstringThe user ID of the comment author (optional).

Returns

ApiComment

Example

This example adds a comment to all contents of the table.

let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
doc.Push(table);
let paragraph = Api.CreateParagraph();
paragraph.AddText("This is just a sample text in the first cell.");
let cell = table.GetCell(0, 0);
table.AddElement(cell, 0, paragraph);
table.AddComment("comment", "John Smith");