Reading from Multiple files

3 visualizzazioni (ultimi 30 giorni)
Unnikrishnan PC
Unnikrishnan PC il 21 Apr 2013
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

Risposte (1)

Walter Roberson
Walter Roberson il 21 Apr 2013

Community Treasure Hunt

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

Start Hunting!

Translated by