Excel.BindingCollection class

ブックの一部であるすべてのバインド オブジェクトのコレクションを表します。

Extends

注釈

[ API セット: ExcelApi 1.1 ]

プロパティ

context

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

count

コレクション内にあるバインドの数を取得します。

items

このコレクション内に読み込まれた子アイテムを取得します。

メソッド

getItem(id)

ID を使用してバインド オブジェクトを取得します。

getItemAt(index)

項目の配列内の位置に基づいて、バインド オブジェクトを取得します。

load(options)

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

load(propertyNames)

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

load(propertyNamesAndPaths)

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

toJSON()

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

プロパティの詳細

context

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

context: RequestContext;

プロパティ値

count

コレクション内にあるバインドの数を取得します。

readonly count: number;

プロパティ値

number

注釈

[ API セット: ExcelApi 1.1 ]

items

このコレクション内に読み込まれた子アイテムを取得します。

readonly items: Excel.Binding[];

プロパティ値

メソッドの詳細

getItem(id)

ID を使用してバインド オブジェクトを取得します。

getItem(id: string): Excel.Binding;

パラメーター

id

string

取得するバインド オブジェクトの ID。

戻り値

注釈

[ API セット: ExcelApi 1.1 ]

async function onBindingDataChanged(eventArgs) {
    await Excel.run(async (context) => { 
        // Highlight the table related to the binding in orange to indicate data has been changed.
        context.workbook.bindings.getItem(eventArgs.binding.id).getTable().getDataBodyRange().format.fill.color = "Orange";
        await context.sync();
        
        console.log("The value in this table got changed!");
    });
}

getItemAt(index)

項目の配列内の位置に基づいて、バインド オブジェクトを取得します。

getItemAt(index: number): Excel.Binding;

パラメーター

index

number

取得するオブジェクトのインデックス値。 0 を起点とする番号になります。

戻り値

注釈

[ API セット: ExcelApi 1.1 ]

await Excel.run(async (context) => { 
    const lastPosition = context.workbook.bindings.count - 1;
    const binding = context.workbook.bindings.getItemAt(lastPosition);
    binding.load('type')
    await context.sync();

    console.log(binding.type);
});

load(options)

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

load(options?: Excel.Interfaces.BindingCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.BindingCollection;

パラメーター

options

Excel.Interfaces.BindingCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions

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

戻り値

load(propertyNames)

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

load(propertyNames?: string | string[]): Excel.BindingCollection;

パラメーター

propertyNames

string | string[]

読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。

戻り値

await Excel.run(async (context) => { 
    const bindings = context.workbook.bindings;
    bindings.load('items');
    await context.sync();

    for (let i = 0; i < bindings.items.length; i++) {
        console.log(bindings.items[i].id);
    }
});

load(propertyNamesAndPaths)

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

load(propertyNamesAndPaths?: OfficeExtension.LoadOption): Excel.BindingCollection;

パラメーター

propertyNamesAndPaths
OfficeExtension.LoadOption

propertyNamesAndPaths.select は、読み込むプロパティを指定するコンマ区切り文字列で propertyNamesAndPaths.expand 、読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。

戻り値

toJSON()

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

toJSON(): Excel.Interfaces.BindingCollectionData;

戻り値