xlsread
- 读取 Microsoft Excel 电子表格文件
不推荐使用
xlsread。请改用readtable、readmatrix或readcell。语法
[num = xlsread(filename)](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#d122e1401239)[num = xlsread(filename,sheet)](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#d122e1401264)[num = xlsread(filename,xlRange)](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#d122e1401279)[num = xlsread(filename,sheet,xlRange)](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#d122e1401302)[num = xlsread(filename,sheet,xlRange,'basic')](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#d122e1401322)[[num,txt,raw] = xlsread(**___**)](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#d122e1401369)[**___** = xlsread(filename,-1)](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#d122e1401396)[[num,txt,raw,custom] = xlsread(filename,sheet,xlRange,'',processFcn)](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#d122e1401426)说明
`[num](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-num)= xlsread(filename)读取名为filename` 的 Microsoft Excel电子表格工作表中的第一个工作表,并在一个矩阵中返回数值数据。`[num](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-num)= xlsread(filename,sheet)` 读取指定的工作表。`[num](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-num)= xlsread(filename,xlRange)从工作簿的第一个工作表的指定范围内读取数据。使用 Excel 范围语法,例如‘A1:C3’`。`[num](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-num)= xlsread(filename,sheet,xlRange)` 读取指定的工作表和范围。[num](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-num) = xlsread([filename](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-filename),[sheet](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-sheet),[xlRange](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-xlRange),[‘basic’](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-basic))在basic导入模式下读取电子表格中的数据。- 如果您的计算机未安装Windows版 Excel 或者您正在使用 MATLAB Online,
xlsread会自动在basic导入模式下运行,该模式支持 XLS、XLSX、XLSM、XLTX 和 XLTM 文件。 - 如果不指定所有参数,请使用空字符向量
''作为占位符,例如,num = xlsread(filename,'','','basic')。
- 如果您的计算机未安装Windows版 Excel 或者您正在使用 MATLAB Online,
[[num](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-num),[txt](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-txt),[raw](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-raw)] = xlsread(**___**)还使用先前语法中的任何输入参数,在元胞数组txt中返回文本字段,在元胞数组raw中返回数值数据和文本数据。**___** = xlsread([filename](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-filename),-1)打开一个 Excel 窗口以便按交互方式来选择数据。选择工作表,将鼠标拖放到所需范围上,然后点击确定。只有安装了 Microsoft Excel 软件的 Windows 计算机才支持此语法。[[num](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-num),[txt](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-txt),[raw](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-raw),[custom](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-custom)] = xlsread([filename](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-filename),[sheet](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-sheet),[xlRange](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-xlRange),'',[processFcn](https://ww2.mathworks.cn/help/matlab/ref/xlsread.html#btg5vmt-1-processFcn))(其中processFcn是函数句柄)读取电子表格,对数据调用processFcn,并在数组num中以数值数据的形式返回最终结果。xlsread函数在元胞数组txt中返回文本字段、在元胞数组raw中返回数值和文本数据,并在数组custom中返回processFcn的第二个输出。xlsread函数不会更改电子表格中存储的数据。只有安装了 Excel 软件的 Windows 计算机才支持此语法。
