Import - Maple Help

ExcelTools

 Import
 import data from an Excel spreadsheet

 Calling Sequence Import(file, sheet, cells, emptycell=value)

Parameters

 file - (optional in Standard interface) string; the name of the Excel file from which to import data sheet - (optional) string or positive integer; the name or index of the sheet from which to import data (default: 1) cells - (optional) string; the cell range to import (default: the entire sheet) value - (optional) anything; the value given to blank cells in the spreadsheet (default is 0.0)

Options

 • labeltype : one of symbol or string
 When output=DataFrame, this option specifies whether non-numeric row and column labels should be expressed as symbols or strings when constructing the DataFrame.
 The default is symbol.
 • output : one of Matrix or DataFrame
 This option specifies the desired method for representing the imported data in Maple.
 The default is Matrix.

Description

 • The Import(file,sheet,cells) function imports the data from the Microsoft Excel workbook file, as addressed by the sheet and cells parameter, into a Matrix.
 • Both the XLSX (Office Open XML) and XLS (Excel 97-2003) file formats are supported.
 • In the Standard interface, if the file parameter is not provided, a dialog will be presented with a field for the target file name.  In all other interfaces, the file parameter is required.
 • The sheet parameter can be either the name of a sheet within the file or a 1-based index.
 • The cells parameter can be a standard cell range, for example, "A1:B9" or "c$10..$w15", or a named range.  If it is given as a named range, that name must already exist in the Excel file.
 • If cells is given as a single cell address, for example "D13", this is taken as the top-left corner of the required range, with the bottom-right corner taken to be the bottom-right corner of the sheet. (To import just a single cell, specify it as a range, for example "AQ3:AQ3".)
 • Spreadsheets can contain empty cells in the midst of other data.  By default these cells are given the value 0.0 upon import.  Use the emptycell option to specify a different value.  For example, emptycell=undefined, or emptycell="".

Examples

To perform the following examples, you should create an Excel spreadsheet named Employees.xlsx with the necessary sheets and cells.

 > $\mathrm{with}\left(\mathrm{ExcelTools}\right):$
 > $Q≔\mathrm{Import}\left("Employees.xlsx","Payroll","B2:C9"\right):$

Indexing only the upper left corner brings in all the rest of the sheet

 > $R≔\mathrm{Import}\left("Employees.xlsx","Payroll","B2"\right):$
 > $\mathrm{ArrayDims}\left(R\right)$
 ${1}{..}{12}{,}{1}{..}{10}$ (1)

A cell range can be specified via a name

 > $P≔\mathrm{Import}\left("Employees.xlsx","FirstQuarter"\right):$

Sheets can be indexed as well as named

 > $S≔\mathrm{Import}\left("Employees.xlsx",2,"A1:w25"\right):$

Import all of the first (or only) sheet

 > $T≔\mathrm{Import}\left("Employees.xlsx"\right):$

(Standard interface only) Open a dialog to enter the file name and other data

 > $T≔\mathrm{Import}\left(\right)$

Compatibility

 • The ExcelTools[Import] command was updated in Maple 2023.
 • The labeltype and output options were introduced in Maple 2023.