跳到主要内容

AddUser

将用户设置到当前受保护区域。

语法

expression.AddUser(sId, sName, protectedRangeUserType);

expression - 表示 ApiProtectedRange 类的变量。

参数

名称必需/可选数据类型默认值描述
sId必需string用户 ID。
sName必需string用户名。
protectedRangeUserType必需ProtectedRangeUserType受保护区域的用户类型。

返回值

ApiProtectedRangeUserInfo | null

示例

此示例为受保护区域添加用户。

// How to open an access for the protected range to user specifing user id, name and access type.

// Get an active sheet, add protected range to it and add user with rights.

let worksheet = Api.GetActiveSheet();
worksheet.AddProtectedRange("protectedRange", "$A$1:$B$1");
let protectedRange = worksheet.GetProtectedRange("protectedRange");
protectedRange.AddUser("userId", "name", "CanView");