How to import a mass of excel documents into a table

조회 수: 8 (최근 30일)
N Reichen
N Reichen 2017년 8월 2일
댓글: N Reichen 2017년 8월 3일
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

답변 (1개)

Akhilesh Thakur
Akhilesh Thakur 2017년 8월 2일
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
N Reichen
N Reichen 2017년 8월 3일
My MatLAB skills are very sparse, so I'm not sure how to use actxserver

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by