Wählen Sie für diese API die Als am wenigsten privilegierten Berechtigungen gekennzeichneten Berechtigungen aus. Verwenden Sie nur dann eine Berechtigung mit höheren Berechtigungen , wenn dies für Ihre App erforderlich ist. Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen. Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz.
Berechtigungstyp
Berechtigungen mit den geringsten Berechtigungen
Berechtigungen mit höheren Berechtigungen
Delegiert (Geschäfts-, Schul- oder Unikonto)
Files.ReadWrite
Nicht verfügbar.
Delegiert (persönliches Microsoft-Konto)
Files.ReadWrite
Nicht verfügbar.
Anwendung
Nicht unterstützt
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
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Drives.Item.Items.Item.Workbook.Worksheets.Item.Protection.Protect;
using Microsoft.Graph.Models;
var requestBody = new ProtectPostRequestBody
{
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,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Workbook.Worksheets["{workbookWorksheet-id}"].Protection.Protect.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.drives.item.items.item.workbook.worksheets.item.protection.protect.ProtectPostRequestBody protectPostRequestBody = new com.microsoft.graph.drives.item.items.item.workbook.worksheets.item.protection.protect.ProtectPostRequestBody();
WorkbookWorksheetProtectionOptions options = new WorkbookWorksheetProtectionOptions();
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);
protectPostRequestBody.setOptions(options);
graphClient.drives().byDriveId("{drive-id}").items().byDriveItemId("{driveItem-id}").workbook().worksheets().byWorkbookWorksheetId("{workbookWorksheet-id}").protection().protect().post(protectPostRequestBody);