MATLAB: Create table from excel spreadsheet with multiple sheets

data importMATLAB

Suppose I have xlsx file with multiple sheets. I want to create table A from the first sheet and create table B from the second sheet. Please advise.

Best Answer

Try this:
folder = fileparts(which('patients.xls')) % Determine where demo folder is.
fullFileName = fullfile(folder, 'patients.xls');
[status, sheetNames] = xlsfinfo(fullFileName)
numSheets = length(sheetNames)
t1 = readtable(fullFileName, 'Sheet', 1)
t2 = readtable(fullFileName, 'Sheet', 2)
and so on. Put in a loop if you want.