Skip to content

excelTable

Copy a table from another Excel file and return the table name.

excelTable(
    workbookPath,
    tableName,
    query="",
    dataTypes=dict()
)

Duplicate column names

If there are multiple columns with the same name, only the left-most column is kept. Column names are case-insensitive. For more info, see the page about column names.

Arguments

workbookPath

A string representation of the path to the source workbook file.

Both absolute and relative paths are supported. If the path is relative, it's considered relative to the model file (e.g. the model workbook). Environment variables (e.g. %temp% or %homepath%) are also supported.

tableName

The name of the table to load from the source workbook.

This can either be the name of an Excel table (ListObject) or named range with at least one column and at least two rows (one header row and one data row).

query

An optional query to be applied to the table. See SQL queries for details.

An empty argument or empty string here means that no query will be performed, i.e. all data from the table will be used.

dataTypes

A mapping of column names to data type specifiers. See data types for details.

For columns not given in dataTypes, the data types and number formats of the source table will be used. However, sometimes you may want to override the data type of a column, or the SQL query may return columns which are not present in the source table. In these cases, you can use this argument to specify the data types of the columns.

Examples

See the example workbook.