跳到主要内容

GetUser

返回表示当前受保护区域中用户的对象。

语法

expression.GetUser(sId);

expression - 表示 ApiProtectedRange 类的变量。

参数

名称必需/可选数据类型默认值描述
sId必需string用户 ID。

返回值

ApiProtectedRangeUserInfo | null

示例

此示例获取受保护区域的用户。

// How to get a user information of the protected range.

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

let worksheet = Api.GetActiveSheet();
worksheet.AddProtectedRange("protectedRange", "$A$1:$B$1").AddUser("userId", "name", "CanView");
let protectedRange = worksheet.GetProtectedRange("protectedRange");
let userInfo = protectedRange.GetUser("userId");
let userName = userInfo.GetName();
worksheet.GetRange("A3").SetValue("User name: " + userName);