跳到主要内容

AddComment

向当前范围添加批注。

语法

expression.AddComment(sText, sAuthor);

expression - 表示 ApiRange 类的变量。

参数

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

返回值

ApiComment | null

示例

此示例向范围添加批注。

// How to comment a range.

// Get a range from the worksheet, add a comment to it and then show the comments text.

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());