请教matlab如何​获取Excel工作表​的最后一行?。

6 visualizaciones (últimos 30 días)
gkbewt
gkbewt el 22 de Mayo de 2023
Respondida: hvvarpe el 22 de Mayo de 2023
以前我在 excel vba中用如下语句可以获取工作表的最后一行
ws.Cells(1,1).End(xlUp).row
但是该语句在matlab中会报错:函数或变量 'xlUp' 无法识别。
(说明:ws为工作表对象, ws.Cells(1,1)是获取第A1单元格,ws.Cells(1,1).End(xlUp)是获取第1列的有内容的最后一行,ws.Cells(1,1).End(xlUp).row是获取最后一行的行号。)
请问这个语句该怎么修改?或者有什么其他方法获取最后一行?
如果能告诉在哪里可以查到matlab操作Excel的函数说明,那就更好了
(Excel vba的函数语句不能直接用到matlab中)
谢谢!

Respuesta aceptada

hvvarpe
hvvarpe el 22 de Mayo de 2023
调用CountA函数 数据连续的话
exl = actxserver('excel.application');
exlWkbk = exl.Workbooks;
exlFile = exlWkbk.Open([docroot '/techdoc/matlab_external/examples/input_resp_data.xls']);%自带文件
exlSheet1 = exlFile.Sheets.Item('Sheet1');
Rows=exl. Application.WorksheetFunction.CountA(exlSheet1.Range('A:A'))
Rows =1590

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!