Combining excel files in a single file

3 ビュー (過去 30 日間)
manish sharma
manish sharma 2013 年 2 月 4 日
コメント済み: Rajendra Shrestha 2020 年 10 月 12 日
Hey,
I have several files by the name try_1, try_2,.....try_1000.xlsx (which all have a column vector stored in it)
How can I combine them in a single xlsx file (that will have a matrix containing 1000 columns of all those files)?
Any help in this regard will be greatly appreciated.
Thanks

採用された回答

Cedric
Cedric 2013 年 2 月 4 日
You could do something like that (not tested):
nRows = .. you define it.
nCols = 1000 ;
buffer = zeros(nRows, nCols) ;
for ii = 1 : 1000
buffer(:,ii) = xlsread(sprintf('try_%d.xlsx', ii)) ;
end
xlswrite('allTries.xlsx', buffer) ;
  1 件のコメント
Rajendra Shrestha
Rajendra Shrestha 2020 年 10 月 12 日
It works well. Thanks..

サインインしてコメントする。

その他の回答 (1 件)

Jose Jeremias Caballero
Jose Jeremias Caballero 2013 年 2 月 4 日
編集済み: Jose Jeremias Caballero 2013 年 2 月 4 日
list=dir([pwd,'/try_*.xlsx']);
for i=1:length(list);
A(:,i)=xlsread(list(i).name);
end
xlswrite('TRYS.xlsx',A)
Both excel files and this code must be in the same folder to work. You can also more generic, ie Excel files can be in any folder, and for that you use the command uigetdir ()
Tanto los archivos excel y este código deben de estar en una misma carpeta para funcione. También puede hacer mas genérico, es decir los archivos Excel pueden estar en cualquier carpeta, y para eso se usa el comando uigetdir()

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by