calling specific sheet of excel after importdata

26 views (last 30 days)
Hi I have a excel file with around 20 sheets. I am importing data using mydata = importdata('myfile.xlsx') ;
Now mydata is a structure. This has two substructures; data and textdata. Using mydata.data I am able to get the sheets which are present in the excel file. I want to run a loop such that I can call the specific sheet from mydata.data . Is there any way to do this?
Thanks in advance
Sreenu

Accepted Answer

KSSV
KSSV on 5 Mar 2012
Hi Oleg Komarov, thanks for the reply.
I have many sheets in excel file and every time I want to use a particular number in every sheet. So I have to import all the sheets and run a loop. SO importdata is useful for me. I got to know how to call a particular sheet by indexing it. The following piece of CODE worked:
[type, sheets] = xlsfinfo('myfile.xlsx') ;
present = myfile.data.(char(sheets(i))) ;
Sreenu

More Answers (1)

Oleg Komarov
Oleg Komarov on 3 Mar 2012
Yes, use xlsread within a for loop specifying the sheet to import.
for s = 1:20
data.(mydata.data{s}) = xlsread('C:...filename',mydata.data{s})
end

Community Treasure Hunt

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

Start Hunting!