How to import XLS files with multiple sheets using the Dataset Array function?

1 次查看(过去 30 天)
LS,
I would like to import a XLS file which has multiple worksheets in it using the dataset array function. Is this possible? When I use the standard code below it just imports the first worksheet.
A = dataset('XLSFile',filename,'ParamName',Value)
Your help is much appreciated.
Best regards,
Frits Hermans

回答(1 个)

Oleg Komarov
Oleg Komarov 2011-5-3
Use a loop as described in the FAQ 4.12
example (same type dataset on 2 excel sheets):
A = cell(2,1);
for ii = 1:2 % number of sheets
A{ii} = dataset('XLSFile','test.xlsx','sheet',ii);
end
cat(1,A{:})
  2 个评论
Frits
Frits 2011-5-5
Hi Oleg,
Thanks a lot for your reply.
Unfortunately it does not work. I get the error:
??? Error using ==> setvarnames at 26
NEWNAMES must be a nonempty string or a cell array of nonempty strings.
Error in ==> dataset.dataset>readXLSFile at 723
a = setvarnames(a,varnames(:)'); % names will be modified to make them valid
Error in ==> dataset.dataset>dataset.dataset at 353
a = readXLSFile(a,xlsfileArg,otherArgs);
Do you probably know what this error means?
best regards,
Frits
Oleg Komarov
Oleg Komarov 2011-5-5
Edit your original post adding the FORMATTED code you're using. In addition post the first three lines of the exceel sheet.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by