[num,txt,raw]
= xlsread(___) additionally returns the text
fields in cell array txt, and both numeric and
text data in cell array raw, using any of the
input arguments in the previous syntaxes.

___ = xlsread(filename,-1) opens
an Excel window to interactively select data. Select the worksheet,
drag and drop the mouse over the range you want, and click OK.
This syntax is supported only on Windows computers with Microsoft
Excel software
installed.

[num,txt,raw,custom]
= xlsread(filename,sheet,xlRange,'',processFcn),
where processFcn is a function handle, reads from
the spreadsheet, calls processFcn on the data,
and returns the final results as numeric data in array num.
The xlsread function returns the text fields in
cell array txt, both the numeric and text data
in cell array raw, and the second output from processFcn in
array custom. The xlsread function
does not change the data stored in the spreadsheet. This syntax is
supported only on Windows computers with Excel software.

Input Arguments

filename — File namecharacter vector | string

File name, specified as a character vector or a string. If you
do not include an extension, xlsread searches for
a file with the specified name and a supported Excel extension. xlsread can read data saved in files
that are currently open in Excel for Windows.

Example: 'myFile.xlsx' or "myFile.xlsx"

Data Types: char | string

sheet — Worksheetcharacter vector | string | positive integer

Worksheet, specified as one of the following:

Character vector or string that contains the worksheet
name. The name cannot contain a colon (:). To determine
the names of the sheets in a spreadsheet file, use xlsfinfo.
For XLS files in basic mode, sheet is
case sensitive.

Positive integer that indicates the worksheet index. This option is not supported for XLS files in basic mode.

xlRange — Rectangular rangecharacter vector | string

Rectangular range, specified as a character vector or a string.

Specify xlRange using two opposing corners
that define the region to read. For example, 'D2:H4' represents
the 3-by-5 rectangular region between the two corners D2 and H4 on
the worksheet. The xlRange input is not case sensitive,
and uses Excel A1 reference style (see Excel help).

Range selection is not supported when reading XLS files
in basic mode. In this case, use '' in
place of xlRange.

If you do not specify sheet, then xlRange must
include both corners and a colon character, even for a single cell
(such as 'D2:D2'). Otherwise, xlsread interprets
the input as a worksheet name (such as 'sales' or 'D2').

If you specify sheet, then xlRange:

Does not need to include a colon and opposite corner
to describe a single cell.

Can refer to a named range that you defined in the Excel file
(see the Excel help).

When the specified xlRange overlaps
merged cells:

On Windows computers with Excel, xlsread expands
the range to include all merged cells.

On computers without Excel for Windows, xlsread returns
data for the specified range only, with empty or NaN values
for merged cells.

processFcn — Handle to a custom functionfunction handle

Handle to a custom function. This argument is supported only
on Windows computers with Excel software. xlsread reads
from the spreadsheet, executes your function on a copy of the data,
and returns the final results. xlsread does not
change the data stored in the spreadsheet.

When xlsread calls the custom function, it
passes a range interface from the Excel application to provide
access to the data. The custom function must include this interface
both as an input and output argument. (See Execute a Function on a Worksheet)

Example: @myFunction

Output Arguments

num — Numeric datamatrix

Numeric data, returned as a matrix of double values.
The array does not contain any information from header lines, or from
outer rows or columns that contain nonnumeric data. Text data in inner
spreadsheet rows and columns appear as NaN in the num output.

txt — Text datacell array

Text data, returned as a cell array. Numeric values in inner
spreadsheet rows and columns appear as empty character vectors, '',
in txt.

For XLS files in basic import mode, the txt output
contains empty character vectors, '', in place
of leading columns of numeric data that precede text data in the spreadsheet.
In all other cases, txt does not contain these
additional columns.

Undefined values (such as '#N/A') appear
in the txt output as '#N/A',
except for XLS files in basic mode.

raw — Numeric and text datacell array

Numeric and text data from the worksheet, returned as a cell
array.

On computers with Excel for Windows,
undefined values (such as '#N/A') appear in the raw output
as 'ActiveX VT_ERROR:'. For XLSX, XLSM, XLTX, and
XLTM files on other computers, undefined values appear as '#N/A'.

custom — Second output of the function corresponding to processFcndefined by the function

Second output of the function corresponding to processFcn.
The value and data type of custom are determined
by the function.

Limitations

xlsread reads only 7-bit ASCII
characters.

xlsread does not support non-contiguous
ranges.

On Linux® platforms, xlsread cannot
open spreadsheet files written by the writetable function.

Algorithms

xlsread imports formatted
text representing dates (such as '10/31/96'), except
in basic mode and on computers without Excel for Windows.