MATLAB Answers

Access to Excel-Worksheet-Cells Property

조회 수: 31(최근 30일)
Andreas
Andreas 5 Jul 2013
I want to access some excel data with a loop over some rows and columns. With vba, I am used to do this with the cell-property (!). That's my attemp in matlab:
excelObject = actxserver('Excel.Application');
excelObject.Visible = 1;
oWorkbook = excelObject.Workbooks.Open('C:\abc.xls');
oWorksheet = oWorkbook.Sheets.Item(1);
oWorksheet.Activate;
% Here I want to get the address of cell B2:
disp oWorksheet.Cells(2,2).Address;
% The error Index exceeds matrix dimensions occures
It looks like matlab wants to use the Cell-Property as an array - not as a property with two arguments.
How can I access the Cells-Property? I tried the "get"-Function, but this doesn't help me.
Regards
Andreas

  댓글 수: 0

로그인 to comment.

채택된 답변

Friedrich
Friedrich 5 Jul 2013
Hi,
use this:
get(get(oWorksheet,'Cells',2,2),'Address')

  댓글 수: 1

Andreas
Andreas 8 Jul 2013
Thanks a lot.

로그인 to comment.

More Answers (1)

Tom
Tom 5 Jul 2013
oWorksheet.Range('B2')

  댓글 수: 1

Andreas
Andreas 8 Jul 2013
Thank you. I want to make a loop through my sheet. That's why I want to use the numeric mode.

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by