Excel.WorkbookProtection class
ブック オブジェクトの保護を表します。
- Extends
注釈
プロパティ
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| protected | ブックが保護されているかどうかを指定します。 |
メソッド
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| protect(password) | ブックを保護します。 ブックが保護されている場合は失敗します。 |
| toJSON() | API オブジェクトが |
| unprotect(password) | ブックの保護を解除します。 |
プロパティの詳細
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
protected
メソッドの詳細
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: Excel.Interfaces.WorkbookProtectionLoadOptions): Excel.WorkbookProtection;
パラメーター
読み込むオブジェクトのプロパティのオプションを提供します。
戻り値
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNames?: string | string[]): Excel.WorkbookProtection;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。
戻り値
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Excel.WorkbookProtection;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列で、 propertyNamesAndPaths.expand は読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。
戻り値
protect(password)
ブックを保護します。 ブックが保護されている場合は失敗します。
protect(password?: string): void;
パラメーター
- password
-
string
ブック保護パスワード。
戻り値
void
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/data-protection.yaml
let password = await passwordHandler();
passwordHelper(password);
await Excel.run(async (context) => {
let workbook = context.workbook;
workbook.load("protection/protected");
await context.sync();
if (!workbook.protection.protected) {
workbook.protection.protect(password);
}
});
toJSON()
API オブジェクトがJSON.stringify()に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (JSON.stringify、それに渡されるオブジェクトの toJSON メソッドを呼び出します)。元の Excel.WorkbookProtection オブジェクトは API オブジェクトですが、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( Excel.Interfaces.WorkbookProtectionData として型指定) を返します。
toJSON(): Excel.Interfaces.WorkbookProtectionData;
戻り値
unprotect(password)
ブックの保護を解除します。
unprotect(password?: string): void;
パラメーター
- password
-
string
ブック保護パスワード。
戻り値
void
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/data-protection.yaml
let password = await passwordHandler();
passwordHelper(password);
await Excel.run(async (context) => {
let workbook = context.workbook;
workbook.protection.unprotect(password);
});