ExcelScript.Query interface

Represents a Power Query query.

Remarks

Examples

/**
 * This script logs information about all the Power Query queries in the workbook.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get all the Power Query queries in the workbook.
  const queries = workbook.getQueries();

  // For each query, log the date it was last refreshed.
  queries.forEach((query: ExcelScript.Query) => {
    console.log(`Query ${query.getName()} - last refreshed ${query.getRefreshDate()}`);
  });
}

Methods

getError()

Gets the query error message from when the query was last refreshed.

getLoadedTo()

Gets the query loaded to object type.

getLoadedToDataModel()

Specifies if the query loaded to the data model.

getName()

Gets the name of the query. Query names cannot contain periods or quotation marks.

getRefreshDate()

Gets the date and time when the query was last refreshed.

getRowsLoadedCount()

Gets the number of rows that were loaded when the query was last refreshed. If last refresh has errors the value will be -1.

Method Details

getError()

Gets the query error message from when the query was last refreshed.

getError(): QueryError;

Returns

getLoadedTo()

Gets the query loaded to object type.

getLoadedTo(): LoadToType;

Returns

getLoadedToDataModel()

Specifies if the query loaded to the data model.

getLoadedToDataModel(): boolean;

Returns

boolean

getName()

Gets the name of the query. Query names cannot contain periods or quotation marks.

getName(): string;

Returns

string

getRefreshDate()

Gets the date and time when the query was last refreshed.

getRefreshDate(): Date;

Returns

Date

getRowsLoadedCount()

Gets the number of rows that were loaded when the query was last refreshed. If last refresh has errors the value will be -1.

getRowsLoadedCount(): number;

Returns

number