Reading from Multiple files
2 次查看(过去 30 天)
显示 更早的评论
I have my code as listed below reading from 60 files. Is it possible to reduce this coding? Please help.
ex = actxserver('excel.application');
ex.visible = 1;
%---------------------------------------------------
exwb1 = ex.Workbooks.Open('C:\Advisory\1.xls');
exwb2 = ex.Workbooks.Open('C:\Advisory\2.xls');
:
:
exwb60 = ex.Workbooks.Open('C:\Advisory\60.xls');
%---------------------------------------------------
exSheet1=exwb1.Sheets.Item('Compile');
exSheet2=exwb2.Sheets.Item('Compile');
:
:
exSheet60=exwb60.Sheets.Item('Compile');
%---------------------------------------------------
for j=[2:16 21:27]
L=xlsColStr(j);
i=7;
val1 = exSheet1.Range([L,num2str(i)]).get('Value');
val2 = exSheet2.Range([L,num2str(i)]).get('Value');
:
:
val59 = exSheet59.Range([L,num2str(i)]).get('Value');
sum=val1+val2+.......+val59;
exSheet60.Range([L,num2str(i)]).set('Value',sum);
end
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!