I have the following script for gathering information about Excel files under investigation:
clear allpathName='F:\path'; TopFolder = pathName; dirListing = dir(TopFolder); dirListing=dirListing(3:end);%first 2 are just pointers
%obtain the name of each of the excel file:
for i=1:length(dirListing); SubFolder{i}=dirListing(i,1).name; SubFolderPath{i} = fullfile(pathName, dirListing(i,1).name); ExcelFile{i}=dir(fullfile(SubFolderPath{i},'*.xls')); for j=1:length(ExcelFile{1,i}); ExcelFileName{1,i}{j,1}=ExcelFile{1,i}(j,1).name; endend%obtain the name of the worksheets
for i=1:length(ExcelFileName); for k=1:length(ExcelFileName{1,i}); [status{1,i}{k,1},sheets{1,i}{k,1},format{1,i}{k,1}] = xlsfinfo((fullfile(pathName,SubFolder{1,i},ExcelFileName{1,i}{k,1}))); endend
This provides the name of each of the worksheets in the spreadsheet. However, I only want to import the data from one of the worksheets in each of the spreadsheets. Therefore is there a way for matlab to display a list of the worksheet names. So, say that we have 20 worksheet names, could matlab show a message saying something along the lines of 'Select Worksheet' and then have each of the worksheet names shown in 'sheets{1,i}{k,1}' being assigned a number (i.e. from 1-20) then by typing 20 in the command window it would store the name of the last worksheet which could then be used by xlsread to import the data?
Please ask if I'm not clear on what I'm trying to achieve.
Best Answer