Excel.Query class

Power Query クエリを表します。

Extends

注釈

[ API セット: ExcelApi 1.14 ]

プロパティ

context

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

error

クエリが最後に更新されたときのクエリ エラー メッセージを取得します。

loadedTo

オブジェクト型に読み込まれたクエリを取得します。

loadedToDataModel

クエリがデータ モデルに読み込まれるかどうかを指定します。

name

クエリの名前を取得します。 クエリ名にピリオドや引用符を含めることはできません。

refreshDate

クエリが最後に更新された日時を取得します。

rowsLoadedCount

クエリが最後に更新されたときに読み込まれた行の数を取得します。 最後の更新でエラーが発生した場合、値は -1 になります。

メソッド

load(options)

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

load(propertyNames)

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

load(propertyNamesAndPaths)

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

toJSON()

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

プロパティの詳細

context

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

context: RequestContext;

プロパティ値

error

クエリが最後に更新されたときのクエリ エラー メッセージを取得します。

readonly error: Excel.QueryError | "Unknown" | "None" | "FailedLoadToWorksheet" | "FailedLoadToDataModel" | "FailedDownload" | "FailedToCompleteDownload";

プロパティ値

Excel.QueryError | "Unknown" | "None" | "FailedLoadToWorksheet" | "FailedLoadToDataModel" | "FailedDownload" | "FailedToCompleteDownload"

注釈

[ API セット: ExcelApi 1.14 ]

loadedTo

オブジェクト型に読み込まれたクエリを取得します。

readonly loadedTo: Excel.LoadToType | "ConnectionOnly" | "Table" | "PivotTable" | "PivotChart";

プロパティ値

Excel.LoadToType | "ConnectionOnly" | "Table" | "PivotTable" | "PivotChart"

注釈

[ API セット: ExcelApi 1.14 ]

loadedToDataModel

クエリがデータ モデルに読み込まれるかどうかを指定します。

readonly loadedToDataModel: boolean;

プロパティ値

boolean

注釈

[ API セット: ExcelApi 1.14 ]

name

クエリの名前を取得します。 クエリ名にピリオドや引用符を含めることはできません。

readonly name: string;

プロパティ値

string

注釈

[ API セット: ExcelApi 1.14 ]

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

refreshDate

クエリが最後に更新された日時を取得します。

readonly refreshDate: Date;

プロパティ値

Date

注釈

[ API セット: ExcelApi 1.14 ]

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

    console.log("Last refresh date of each query: ")
    console.log("  " + queries.items.map((query) => query.refreshDate).join("\n  "));
});       

rowsLoadedCount

クエリが最後に更新されたときに読み込まれた行の数を取得します。 最後の更新でエラーが発生した場合、値は -1 になります。

readonly rowsLoadedCount: number;

プロパティ値

number

注釈

[ API セット: ExcelApi 1.14 ]

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

    console.log("Rows loaded from each query: ")
    console.log("  " + queries.items.map((query) => query.rowsLoadedCount).join("\n  "));
});

メソッドの詳細

load(options)

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

load(options?: Excel.Interfaces.QueryLoadOptions): Excel.Query;

パラメーター

options
Excel.Interfaces.QueryLoadOptions

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

戻り値

load(propertyNames)

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

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

パラメーター

propertyNames

string | string[]

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

戻り値

load(propertyNamesAndPaths)

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

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Excel.Query;

パラメーター

propertyNamesAndPaths

{ select?: string; expand?: string; }

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

戻り値

toJSON()

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

toJSON(): Excel.Interfaces.QueryData;

戻り値