vik
vik

Reputation: 3

Matlab: Excel COM actxserver read entire sheet

I have a large number of measurement data in excel files. I need to read and process this data using matlab. The problem I have is that not all excel files contain the same amount of data.

I have tried the following

excel = actxserver('excel.application');
xlswb = excel.Workbook.Open(myFile);
data = xlswb.Sheets.Item(mySheet).get('Range', 'A1', 'L10000').Value;

This "works" as there will not be more than 10000 rows and 8 columns (in my case). However, this is very dirty code and I have to check for each file where the data actually ends.

Is there a way to read a whole sheet (similar to the xlsread function)?

Thanks!

Upvotes: 0

Views: 1567

Answers (1)

Amen Jlili
Amen Jlili

Reputation: 1944

Sheets("SheetName").UsedRange will get you a collection every used cell in that sheet. However, if cell L10000 had data and it was cleared, it will still make part of that collection.

Upvotes: 0

Related Questions