Reading from Multiple files
조회 수: 1 (최근 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!