Reading from Multiple files

조회 수: 1 (최근 30일)
Unnikrishnan PC
Unnikrishnan PC 2013년 4월 21일
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

답변 (1개)

Walter Roberson
Walter Roberson 2013년 4월 21일

카테고리

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