跳到主要内容

AddComment

向当前范围添加批注。

语法

expression.AddComment(sText, sAuthor);

expression - 表示 ApiRange 类的变量。

参数

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

返回值

ApiComment | null

示例

在电子表格中为单元格范围附加注释。

// How do I add a comment to a range of cells in a spreadsheet?

// Leave a written remark on a cell so other users see context when they open it in a spreadsheet.

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