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.
sAuthorOptionalstringThe author's name.
sUserIdOptionalstringThe user ID of the comment author.

Returns

ApiComment

Example

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

// How to add comment to the table indicating its author name.

// Insert a comment into a 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");