Excel.QueryCollection class

ブック内のクエリのコレクションを表します。

Extends

注釈

[ API セット: ExcelApi 1.14 ]

プロパティ

context

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

items

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

メソッド

getCount()

ブック内のクエリの数を取得します。

getItem(key)

コレクションの名前に基づいてクエリを取得します。

load(options)

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

load(propertyNames)

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

load(propertyNamesAndPaths)

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

toJSON()

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

プロパティの詳細

context

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

context: RequestContext;

プロパティ値

items

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

readonly items: Excel.Query[];

プロパティ値

// This function retrieves the query collection in a workbook, 
// loads the query items in that collection, and then
// logs the name of each query to the console.
await Excel.run(async (context) => {
    const queries = context.workbook.queries; 
    queries.load("items"); 
    await context.sync(); 

    console.log("Name of each query: ")
    console.log("  " + queries.items.map((query) => query.name).join("\n  "));
});

メソッドの詳細

getCount()

ブック内のクエリの数を取得します。

getCount(): OfficeExtension.ClientResult<number>;

戻り値

注釈

[ API セット: ExcelApi 1.14 ]

// This function retrieves the query collection in a workbook and then 
// logs the number of queries in the collection to the console.
await Excel.run(async (context) => { 
  const queries = context.workbook.queries; 
  const count = queries.getCount();
  await context.sync();

  console.log("Query count: " + count.value);
});

getItem(key)

コレクションの名前に基づいてクエリを取得します。

getItem(key: string): Excel.Query;

パラメーター

key

string

大文字と小文字を区別しないクエリの名前。

戻り値

指定した名前のクエリ。 その名前のクエリがない場合は、エラーがスローされます。

注釈

[ API セット: ExcelApi 1.14 ]

load(options)

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

load(options?: Excel.Interfaces.QueryCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.QueryCollection;

パラメーター

options

Excel.Interfaces.QueryCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions

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

戻り値

load(propertyNames)

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

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

パラメーター

propertyNames

string | string[]

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

戻り値

load(propertyNamesAndPaths)

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

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

パラメーター

propertyNamesAndPaths
OfficeExtension.LoadOption

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

戻り値

toJSON()

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

toJSON(): Excel.Interfaces.QueryCollectionData;

戻り値