How to import a mass of excel documents into a table

1 view (last 30 days)
N Reichen
N Reichen on 2 Aug 2017
Commented: N Reichen on 3 Aug 2017
I'm trying to import a very large number of excel files from one folder into a table with each excel file being a column and each piece of data (which would be pulled from column B in Excel) as the rows. The code must also be flexible enough to add more Excel files into the folder adding the new data to the table without any errors. This is the code I have so far, but I'm struggling to output any type of table from this.
myfolderinfo = dir('.xlsx');
N = size(myfolderinfo);
n = N(1,1);
pt_txt = cell(302,n);
for i = 1:n
[num,txt,raw] = xlsread(myfolderinfo(i).name);
pt_txt (:,i) = txt(:,2);
end
for i = 1:n
[num,txt,raw] = xlsread(myfolderinfo(i).name);
pt_txt1 (:,i) = txt(:,1);
end
Any help would be appreciated, thanks

Answers (1)

Akhilesh Thakur
Akhilesh Thakur on 2 Aug 2017
https://www.mathworks.com/matlabcentral/newsreader/view_thread/323999 http://www.mathworks.com/help/releases/R2010b/techdoc/ref/xlsread.html Are you using xlsread and using it in a loop to open multiple files? If yes use actxserver before your loop execution so your excel file is kept open. Then close the files after processing. I hope this helps. let me know more questions.
  1 Comment
N Reichen
N Reichen on 3 Aug 2017
My MatLAB skills are very sparse, so I'm not sure how to use actxserver

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!