IMPORT XLS Statement

Imports an Excel worksheet (in either .XLS or .XLSX format) from disk into a notebook table. This statement is the scripting equivalent of the visual import wizard accessed via the Import menu. If the workbook contains multiple worksheets, use the which-sheet argument to specify which worksheet to import. If needed, use the LIST_XLS_WORKSHEETS function to get a list of the worksheets in the workbook.

Syntax


Parameters

Options

Examples

-- Imports the first worksheet in "Workbook.xlsx" into a notebook
-- table called mytable. Because no options are specified, it is
-- assumed that the file has a column header on the first line.
-- Because no column list is specified, all columns are imported
-- as text and the original column names are preserved.
IMPORT XLS 'C:\Workbook.xlsx' INTO mytable;

-- Worksheet can be specified by number or by name.
IMPORT XLS 'C:\Workbook.xlsx' WORKSHEET 1 INTO tbl1;
IMPORT XLS 'C:\Workbook.xlsx' WORKSHEET 'Sheet1' INTO tbl1;

-- The source columns (foo, bar) are explicitly specified. If
-- the source file contains other columns besides those two, then
-- they are not imported into the destination notebook table.
IMPORT XLS 'C:\Workbook.xlsx' INTO mytable (foo, bar);

-- Import a specific range of cells.
IMPORT XLS 'C:\Workbook.xlsx' INTO mytable
OPTIONS (
FIRST_ROW: 1,
LAST_ROW: 5,
FIRST_COLUMN: 'A',
LAST_COLUMN: 'B'
);