Les API sous la version /beta dans Microsoft Graph sont susceptibles d’être modifiées. L’utilisation de ces API dans des applications de production n’est pas prise en charge. Pour déterminer si une API est disponible dans v1.0, utilisez le sélecteur Version .
Protège une feuille de calcul. Générée si la feuille de calcul est protégée.
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.Beta.Drives.Item.Items.Item.Workbook.Worksheets.Item.Protection.Protect;
using Microsoft.Graph.Beta.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.beta.drives.item.items.item.workbook.worksheets.item.protection.protect.ProtectPostRequestBody protectPostRequestBody = new com.microsoft.graph.beta.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);