Creating a loop for several excel files with several sheets

Hey sorry, this is the first time I've asked a question so it might be worded terribly.
I have data on three different excel files, each with approximately 17 sheets. I need to loop through all the excel files and their sheets... not sure how to do that. I have this so far:
if true
names = dir('C:\\Users\emma\Documents\CORES\EXCEL\SAFLCore*_GrainSize.xlsx');
names = {names.name};
filename = names;
for ii = 1:numel(filename)
[status,sheets{ii}] = xlsfinfo('C:\\Users\emma\Documents\CORES\EXCEL\SAFLCore*_GrainSize.xlsx');
end

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 2일
folder='C:\\Users\emma\Documents\CORES\EXCEL';
ff='SAFLCore*_GrainSize.xlsx'
names=dir(fullfile(folder,ff)
filename = {names.name}
for ii = 1:numel(filename)
f=fullfile(folder,filename{ii});
[status,sheets] = xlsfinfo(f);
result=[];
for k=1:numel(sheets)
result{k,1}=xlsread(f,sheets{k})
end
out{ii}=result
end

댓글 수: 4

When I put in the f=fullfile line, only the third excel spreadsheet comes up. As well, the results aren't separate for each excel file
The result are in the variable out
Oh!! Oh okay, I got it! Thank you!
Any way to fix it so that only the "out" result will come into the command window and not the list of other data?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2016년 8월 2일

댓글:

2016년 8월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by