使用MATLAB中的工作表索引调用并提取excel工作表的名称

使用MATLAB中的工作表索引调用并提取excel工作表的名称,excel,matlab,xlsread,Excel,Matlab,Xlsread,我们可以通过xlsread函数调用工作表的名称或索引,如下所示: for i=1:100 file = xlsread(`filename.xlsx`,i) %% I want get name of the called sheet here (storing in cell array) end 在这个循环中,if-want调用并提取指定的工作表名称(使用工作表索引),正如我们在上面循环的注释行中看到的那样,并将名称存储在单元格数组中。如何在Matl

我们可以通过
xlsread
函数调用工作表的名称或索引,如下所示:

    for i=1:100
      file = xlsread(`filename.xlsx`,i)
      %% I want get name of the called sheet here (storing in cell array)
    end
在这个循环中,if-want调用并提取指定的工作表名称(使用工作表索引),正如我们在上面循环的注释行中看到的那样,并将名称存储在单元格数组中。如何在MatlabR2015A中实现这一点?

请参见,它有一个可选的
图纸
输出,返回图纸名称的单元格数组。例如:

xlswrite('test.xlsx', 1:3, 'hi');
xlswrite('test.xlsx', 1:3, 'hello');
xlswrite('test.xlsx', 1:3, 'hey');

[~, sheets] = xlsfinfo('text.xlsx');
返回:

sheets = 

    'Sheet1'    'hi'    'hello'    'hey'
请注意,
Sheet1
之所以出现,是因为我生成了一个空白的电子表格。如果目标工作表中不存在在
xlswrite
调用中指定的工作表名称,则会将其添加到工作簿的末尾

编辑:ActiveX实现:

eAX = actxserver('Excel.Application');
mywb = eAX.Workbooks.Open('C:\test.xlsx');
mysheets = eAX.sheets;
numsheets = mysheets.Count;

sheets = cell(1, numsheets);
for ii = 1:numsheets
    sheets{ii} = eAX.Worksheets.Item(ii).Name;
end

mywb.Close(false)
eAX.Quit

具有工作表名称输出。@excaza。非常感谢。请加上你的答案。