I can find so many examples of going from MATLAB to excel but not the other way around. I don't want to use xlsread because it's super slow and I want to read from multiple sheets within a file and using xlsread for each sheet individually for each file (there are so many files) would take hours. I know how to do the following:
Excel = actxserver('Excel.Application');
set(Excel, 'Visible', 1);
Workbooks = Excel.Workbooks;
exlFile = Workbooks.Open(filename);
eSheets = exlFile.Sheets;
eSheet1 = eSheets.get('Item', sheetname);
eSheet1.Activate;
and then I try to get the range using:
colEnd = eSheet1.Range('A1').End('xlToRight').Column;
rowEnd = eSheet1.Range('A1').End('xlDown').Row;
and then taking the column numbers and converting to letters with numbers using char and dividing by 26. so my variable xlRange looks like 'A1:EO5000' for example because EO is the last column with data and 5000 is the last row with data but then it doesn't accept the following:
Range = get(eSheet1,'Range',xlRange);
out = Range.value;
and gives me Error: Object returned error code: 0x800A03EC which I looked up and it has to do with an improper range.
I know that cell EO5000 is empty because the later columns don't have as many rows as the first ones- but how can I go about reading all the data from the sheet without having problems with the range (and can I just avoid using the range? Is there a better way to do this?)