Read multiple excel file and write into single excel file
9 ビュー (過去 30 日間)
表示 古いコメント
Hi and very good day,
I do have a 100 of excel files and save as thermo1.xls, thermo2.xls......thermo100.xls. Each of the files consist of a row and 20 columns of data on the single sheet (it write on A1 to T1).
The thing that i need to do is, to write all of the data (A1:T1 on thermo1.xls, A1:T1 on thermo2.xls.....) into a single sheet on a new single excel file (it might be saved as finalthermo.xls).
thus, finally the data will be sort (on finalthermo.xls) as (A1:T1 from thermo1.xls, A2:T2 from thermo2.xls......A100:T100 from thermo100.xls)
At the moment, i wrote this code by it wont happen as i wish, all entire row and column were overwrite with data from the last file (thermo100.xls)
source_dir = 'C:\Users\sourcedir.....' %my file source dir
dest_dir = 'C:\Users\destdir.......' %my file dest dir
source_files = dir(fullfile(source_dir, '*.xls'));
for i = 1:length(source_files)
data = xlsread(fullfile(source_dir, source_files(i).name));
for k =1:100
xlswrite('finalthermo.xls',data, 1, sprintf('A%d',(k+1)-1));
end
end
I looking forward for somebody to help me fixing the coding...
thank you.
0 件のコメント
採用された回答
Renato Agurto
2016 年 1 月 6 日
hello
you can try this.
source_dir = 'C:\Users\sourcedir.....' %my file source dir
dest_dir = 'C:\Users\destdir.......' %my file dest dir
source_files = dir(fullfile(source_dir, '*.xls'));
data = zeros(100,20)
for i = 1:length(source_files)
data(i,:) = xlsread(fullfile(source_dir, source_files(i).name));
%or to make sure you only read one line
%data(i,:) = xlsread(fullfile(source_dir, source_files(i).name),1,'A1:T1');
end
xlswrite('finalthermo.xls',data);
その他の回答 (0 件)
参考
カテゴリ
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!