WorksheetProtection: Schützen
Artikel
11/12/2021
2 Minuten Lesedauer
2 Mitwirkende
In diesem Artikel
Namespace: microsoft.graph
Schützen ein Arbeitsblatt. Wird ausgelöst, wenn das Arbeitsblatt geschützt ist.
Berechtigungen
Eine der nachfolgenden Berechtigungen ist erforderlich, um diese API aufrufen zu können. Weitere Informationen, unter anderem zur Auswahl von Berechtigungen, finden Sie im Artikel zum Thema Berechtigungen .
Berechtigungstyp
Berechtigungen (von der Berechtigung mit den wenigsten Rechten zu der mit den meisten Rechten)
Delegiert (Geschäfts-, Schul- oder Unikonto)
Files.ReadWrite
Delegiert (persönliches Microsoft-Konto)
Nicht unterstützt
Anwendung
Nicht unterstützt
HTTP-Anforderung
POST /me/drive/items/{id}/workbook/worksheets/{id|name}/protection/protect
POST /me/drive/root:/{item-path}:/workbook/worksheets/{id|name}/protection/protect
Name
Beschreibung
Authorization
Bearer {token}. Erforderlich.
Arbeitsmappensitzungs-ID
Arbeitsmappensitzungs-ID, die bestimmt, ob Änderungen beibehalten werden. Optional.
Anforderungstext
Geben Sie im Anforderungstext ein JSON-Objekt mit den folgenden Parametern an.
Parameter
Typ
Beschreibung
options
WorkbookWorksheetProtectionOptions
Optional. Optionen für den Arbeitsblattschutz.
Antwort
Wenn die Methode erfolgreich verläuft, wird der Antwortcode 200 OK zurückgegeben. Im Antworttext wird nichts zurückgegeben.
Beispiel
Nachfolgend sehen Sie ein Beispiel dafür, wie diese API aufgerufen wird.
Anforderung
Nachfolgend sehen Sie ein Beispiel der Anforderung.
POST https://graph.microsoft.com/v1.0/me/drive/items/{id}/workbook/worksheets/{id|name}/protection/protect
Content-type: application/json
{
"options": {
"allowFormatCells": true,
"allowFormatColumns": true,
"allowFormatRows": true,
"allowInsertColumns": true,
"allowInsertRows": true,
"allowInsertHyperlinks": true,
"allowDeleteColumns": true,
"allowDeleteRows": true,
"allowSort": true,
"allowAutoFilter": true,
"allowPivotTables": true
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var options = new WorkbookWorksheetProtectionOptions
{
AllowFormatCells = true,
AllowFormatColumns = true,
AllowFormatRows = true,
AllowInsertColumns = true,
AllowInsertRows = true,
AllowInsertHyperlinks = true,
AllowDeleteColumns = true,
AllowDeleteRows = true,
AllowSort = true,
AllowAutoFilter = true,
AllowPivotTables = true
};
await graphClient.Me.Drive.Items["{driveItem-id}"].Workbook.Worksheets["{workbookWorksheet-id}"].Protection
.Protect(options)
.Request()
.PostAsync();
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
const options = {
authProvider,
};
const client = Client.init(options);
const protect = {
options: {
allowFormatCells: true,
allowFormatColumns: true,
allowFormatRows: true,
allowInsertColumns: true,
allowInsertRows: true,
allowInsertHyperlinks: true,
allowDeleteColumns: true,
allowDeleteRows: true,
allowSort: true,
allowAutoFilter: true,
allowPivotTables: true
}
};
await client.api('/me/drive/items/{id}/workbook/worksheets/{id|name}/protection/protect')
.post(protect);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/drive/items/{id}/workbook/worksheets/{id|name}/protection/protect"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
MSGraphWorkbookWorksheetProtectionOptions *options = [[MSGraphWorkbookWorksheetProtectionOptions alloc] init];
[options setAllowFormatCells: true];
[options setAllowFormatColumns: true];
[options setAllowFormatRows: true];
[options setAllowInsertColumns: true];
[options setAllowInsertRows: true];
[options setAllowInsertHyperlinks: true];
[options setAllowDeleteColumns: true];
[options setAllowDeleteRows: true];
[options setAllowSort: true];
[options setAllowAutoFilter: true];
[options setAllowPivotTables: true];
payloadDictionary[@"options"] = options;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
WorkbookWorksheetProtectionOptions options = new WorkbookWorksheetProtectionOptions();
options.allowFormatCells = true;
options.allowFormatColumns = true;
options.allowFormatRows = true;
options.allowInsertColumns = true;
options.allowInsertRows = true;
options.allowInsertHyperlinks = true;
options.allowDeleteColumns = true;
options.allowDeleteRows = true;
options.allowSort = true;
options.allowAutoFilter = true;
options.allowPivotTables = true;
graphClient.me().drive().items("{id}").workbook().worksheets("{id|name}").protection()
.protect(WorkbookWorksheetProtectionProtectParameterSet
.newBuilder()
.withOptions(options)
.build())
.buildRequest()
.post();
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Antwort
Nachfolgend sehen Sie ein Beispiel der Antwort.
HTTP/1.1 200 OK