Excel.WorkbookProtection class

ブック オブジェクトの保護を表します。

Extends

注釈

[ API セット: ExcelApi 1.7 ]

プロパティ

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

protected

ブックが保護されているかどうかを指定します。

メソッド

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

protect(password)

ブックを保護します。 ブックが保護されている場合は失敗します。

toJSON()

API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドを JSON.stringify()オーバーライドします。 (JSON.stringifyさらに、渡される オブジェクトの メソッドを呼び出 toJSON します)。元の Excel.WorkbookProtection オブジェクトは API オブジェクトですが、メソッドは、元の toJSON オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として Excel.Interfaces.WorkbookProtectionData型指定) を返します。

unprotect(password)

ブックの保護を解除します。

プロパティの詳細

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

context: RequestContext;

プロパティ値

protected

ブックが保護されているかどうかを指定します。

readonly protected: boolean;

プロパティ値

boolean

注釈

[ API セット: ExcelApi 1.7 ]

メソッドの詳細

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(options?: Excel.Interfaces.WorkbookProtectionLoadOptions): Excel.WorkbookProtection;

パラメーター

options
Excel.Interfaces.WorkbookProtectionLoadOptions

読み込むオブジェクトのプロパティのオプションを提供します。

戻り値

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

注釈

[ API セット: ExcelApi 1.7 ]

// 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 オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドを JSON.stringify()オーバーライドします。 (JSON.stringifyさらに、渡される オブジェクトの メソッドを呼び出 toJSON します)。元の Excel.WorkbookProtection オブジェクトは API オブジェクトですが、メソッドは、元の toJSON オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として Excel.Interfaces.WorkbookProtectionData型指定) を返します。

toJSON(): Excel.Interfaces.WorkbookProtectionData;

戻り値

unprotect(password)

ブックの保護を解除します。

unprotect(password?: string): void;

パラメーター

password

string

ブック保護パスワード。

戻り値

void

注釈

[ API セット: ExcelApi 1.7 ]

// 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);
});