Borrar filtros
Borrar filtros

Access to Excel-Worksheet-Cells Property

17 visualizaciones (últimos 30 días)
Andreas
Andreas el 5 de Jul. de 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

Respuesta aceptada

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

Más respuestas (1)

Tom
Tom el 5 de Jul. de 2013
oWorksheet.Range('B2')
  1 comentario
Andreas
Andreas el 8 de Jul. de 2013
Thank you. I want to make a loop through my sheet. That's why I want to use the numeric mode.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Import from MATLAB en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by