MATLAB Answers

How to load multiple excel files with multiple excel sheets and store it in matlab faster?

7 views (last 30 days)
Prajwal Venkatesh
Prajwal Venkatesh on 6 Feb 2020
Commented: Prajwal Venkatesh on 10 Feb 2020
I need to load around 50 excel files and each files has like 100+ sheets.
I need to store all this data in variables in my program.
This is the program i have written , I am using activex server and readtable but still it takes around 5 minutes for one excel file.
for i=1:numSheets
t1{1,i} = readtable(fullFileName, 'Sheet', i);
end

  0 Comments

Sign in to comment.

Answers (2)

Subhadeep Koley
Subhadeep Koley on 6 Feb 2020
If you have Parallel Computing Toolbox you can use parfor loop instead of normal for loop. That might decrease the time to read the files.
parfor i = 1:numSheets
t1{:, i} = readtable(fullFileName, 'Sheet', i);
end

Yair Altman
Yair Altman on 9 Feb 2020
Try to use the 'basic' mode of xlsread, which reads the XLS file directly instead of using the much slower Excel instance:
for i=1:numSheets
[~,~,t1{1,i}] = xlsread(fullFileName, i, '', 'basic');
end

Sign in to answer this question.