WorksheetProtection: protect
[アーティクル]
11/12/2021
2 人の共同作成者
この記事の内容
名前空間: microsoft.graph
ワークシートを保護します。ワークシートが保護されている場合はスローします。
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可 」を参照してください。
アクセス許可の種類
アクセス許可 (特権の小さいものから大きいものへ)
委任 (職場または学校のアカウント)
Files.ReadWrite
委任 (個人用 Microsoft アカウント)
サポートされていません。
アプリケーション
サポートされていません。
HTTP 要求
POST /me/drive/items/{id}/workbook/worksheets/{id|name}/protection/protect
POST /me/drive/root:/{item-path}:/workbook/worksheets/{id|name}/protection/protect
名前
説明
Authorization
ベアラー {token}。必須。
Workbook-Session-Id
変更を保持するかどうかを決定するブック セッション ID。省略可能。
要求本文
要求本文で、次のパラメーターを含む JSON オブジェクトを指定します。
パラメーター
型
説明
オプション
WorkbookWorksheetProtectionOptions
省略可能。シートの保護のオプション。
応答
成功した場合、このメソッドは 200 OK 応答コードを返します。応答本文には何も返されません。
例
以下は、この API を呼び出す方法の例です。
要求
以下は、要求の例です。
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();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
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);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
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];
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
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();
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
応答
以下は、応答の例です。
HTTP/1.1 200 OK