Excel.SensitivityLabelDetails class
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
表示 Excel 中可用敏感度标签的属性。
注解
使用方
- Excel.SensitivityLabel: getCurrentOrNullObject
- Excel.SensitivityLabelDetailsCollection: getFirst, getFirstOrNullObject, items
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/98-preview-apis/manage-sensitivity-labels.yaml
// Get the sensitivity label currently applied to the workbook.
await Excel.run(async (context) => {
const workbook: Excel.Workbook = context.workbook;
const workbookLabel: Excel.SensitivityLabel = workbook.sensitivityLabel;
const currentLabel: Excel.SensitivityLabelDetails = workbookLabel.getCurrentOrNullObject();
currentLabel.load(
"color,id,isAbacAttributesRequired,isAbacEnabled,isEnabled,name,order,protectionType,siteId,tooltip"
);
await context.sync();
if (currentLabel.isNullObject) {
console.log("The workbook doesn't have a sensitivity label.");
return;
}
// Get ABAC values only when enabled for the label.
let abacAttributeValues: Excel.SensitivityLabelAbacAttributeValue[] = [];
if (currentLabel.isAbacEnabled) {
currentLabel.load("abacAttributeValues");
await context.sync();
abacAttributeValues = currentLabel.abacAttributeValues;
}
const attributeValues = abacAttributeValues.length
? abacAttributeValues
.map((attributeValue: Excel.SensitivityLabelAbacAttributeValue) =>
`${attributeValue.displayName} (ID: ${attributeValue.id}, ` +
`order: ${attributeValue.displayOrder}, active: ${attributeValue.isActive ? "Yes" : "No"})`)
.join(", ")
: "None";
let protectionDescription: string;
switch (currentLabel.protectionType) {
case Excel.SensitivityLabelProtectionType.adminDefined:
protectionDescription = "Defined by an administrator";
break;
case Excel.SensitivityLabelProtectionType.userDefined:
protectionDescription = "Defined by the user";
break;
case Excel.SensitivityLabelProtectionType.noProtection:
protectionDescription = "No protection";
break;
default:
protectionDescription = `Unknown (${currentLabel.protectionType})`;
break;
}
console.log(
`Current workbook sensitivity label:\n\n${currentLabel.name}\n` +
` ID: ${currentLabel.id}\n` +
` Site ID: ${currentLabel.siteId}\n` +
` Tooltip: ${currentLabel.tooltip}\n` +
` Color: ${currentLabel.color}\n` +
` Enabled: ${currentLabel.isEnabled ? "Yes" : "No"}\n` +
` Display order: ${currentLabel.order}\n` +
` ABAC enabled: ${currentLabel.isAbacEnabled ? "Yes" : "No"}\n` +
` ABAC attributes required: ${currentLabel.isAbacAttributesRequired ? "Yes" : "No"}\n` +
` ABAC attribute values: ${attributeValues}\n` +
` Protection type: ${protectionDescription}`
);
});
属性
| abac |
获取基于属性的访问控制 (ABAC) 当前应用于此敏感度标签的属性值。 未应用 ABAC 属性或此标签未启用 ABAC 时,返回空数组。 |
| children | 获取敏感度标签的子标签。 如果标签没有任何子标签,则集合为空。 |
| color | 获取敏感度标签的颜色。 |
| context | 与对象关联的请求上下文。 这将加载项的进程连接到 Office 主机应用程序的进程。 |
| id | 获取敏感度标签的唯一标识符 (GUID) 。 |
| is |
获取应用此标签是否需要 ABAC 属性选择。 如果 ,调用方在应用标签时必须提供属性值;否则 |
| is |
获取此标签是否是基于属性的访问控制 (启用 ABAC) 。 当主机的标记功能不包括 |
| is |
获取指示是否启用标签的值。 |
| name | 获取敏感度标签的名称。 |
| order | 获取敏感度标签的优先级,其中 0 为最低优先级。 |
| protection |
获取指示此标签提供的保护类型的值。 |
| site |
获取敏感度标签所属租户的唯一标识符 (GUID) 。 |
| tooltip | 获取敏感度标签的说明。 |
方法
| load(options) | 将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 |
| load(property |
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 |
| load(property |
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 |
| toJSON() | 覆盖 JavaScript |
属性详细信息
abacAttributeValues
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取基于属性的访问控制 (ABAC) 当前应用于此敏感度标签的属性值。 未应用 ABAC 属性或此标签未启用 ABAC 时,返回空数组。
readonly abacAttributeValues: SensitivityLabelAbacAttributeValue[];
属性值
注解
children
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取敏感度标签的子标签。 如果标签没有任何子标签,则集合为空。
readonly children: Excel.SensitivityLabelDetailsCollection;
属性值
注解
color
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取敏感度标签的颜色。
readonly color: string;
属性值
string
注解
context
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
与对象关联的请求上下文。 这将加载项的进程连接到 Office 主机应用程序的进程。
context: RequestContext;
属性值
id
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取敏感度标签的唯一标识符 (GUID) 。
readonly id: string;
属性值
string
注解
isAbacAttributesRequired
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取应用此标签是否需要 ABAC 属性选择。 如果 ,调用方在应用标签时必须提供属性值;否则true,更新结果将为statusSensitivityLabelUpdateStatus.abacAttributesRequired。
readonly isAbacAttributesRequired: boolean;
属性值
boolean
注解
isAbacEnabled
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取此标签是否是基于属性的访问控制 (启用 ABAC) 。 当主机的标记功能不包括 attributeBasedAccessControlEnabled时返回false。
readonly isAbacEnabled: boolean;
属性值
boolean
注解
isEnabled
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取指示是否启用标签的值。
readonly isEnabled: boolean;
属性值
boolean
注解
name
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取敏感度标签的名称。
readonly name: string;
属性值
string
注解
order
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取敏感度标签的优先级,其中 0 为最低优先级。
readonly order: number;
属性值
number
注解
protectionType
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取指示此标签提供的保护类型的值。
readonly protectionType: Excel.SensitivityLabelProtectionType | "NoProtection" | "AdminDefined" | "UserDefined";
属性值
Excel.SensitivityLabelProtectionType | "NoProtection" | "AdminDefined" | "UserDefined"
注解
siteId
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取敏感度标签所属租户的唯一标识符 (GUID) 。
readonly siteId: string;
属性值
string
注解
tooltip
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
获取敏感度标签的说明。
readonly tooltip: string;
属性值
string
注解
方法详细信息
load(options)
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(options?: Excel.Interfaces.SensitivityLabelDetailsLoadOptions): Excel.SensitivityLabelDetails;
参数
为要加载的对象属性提供选项。
返回
load(propertyNames)
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(propertyNames?: string | string[]): Excel.SensitivityLabelDetails;
参数
- propertyNames
-
string | string[]
指定要加载的属性的逗号分隔的字符串或字符串数组。
返回
load(propertyNamesAndPaths)
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
将命令加入队列以加载对象的指定属性。 阅读属性前必须先调用 context.sync()。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Excel.SensitivityLabelDetails;
参数
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select 是指定要加载的属性的逗号分隔字符串,以及 propertyNamesAndPaths.expand 指定要加载的导航属性的逗号分隔字符串。
返回
toJSON()
注意
此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。
覆盖 JavaScript toJSON() 方法,以便在将 API 对象传递给 JSON.stringify()时提供更有用的输出。 (JSON.stringify反过来调用 toJSON 传递给它的对象的方法。) 虽然原始 Excel.SensitivityLabelDetails 对象是 API 对象, toJSON 但该方法返回一个纯 JavaScript 对象, (类型化为 Excel.Interfaces.SensitivityLabelDetailsData) ,其中包含从原始对象加载的任何子属性的浅层副本。
toJSON(): Excel.Interfaces.SensitivityLabelDetailsData;