跳到主要内容

AddComment

返回 ApiComment 对象的数组。

语法

expression.AddComment(sText, sAuthor);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
sText必需string批注文本。
sAuthor必需string作者姓名(可选)。

返回值

ApiComment | null

示例

此示例向文档添加批注。

// How to add comments in a worksheet.

// Insert a comment into a cell.

Api.AddComment("Comment 1", "Bob");
Api.AddComment("Comment 2");
let comments = Api.GetComments();
let worksheet = Api.GetActiveSheet();
worksheet.GetRange("A1").SetValue("Comment Text: " + comments[0].GetText());
worksheet.GetRange("B1").SetValue("Comment Author: " + comments[0].GetAuthorName());