Import data from xlsx file - how to import without a specified range
1 view (last 30 days)
Show older comments
Hi,
I am importing data from an *.xlsx file using xlsread.
The range is specified (in my code as 'A3:M4508'). How do I import the file without specifying the range in this way?
The range varies (depending on the data file length) so I like to be able to find the end of the data file (the length) automatically?
The file format is always the same. There are two header rows and the data starts on row A3.
It columns are from A to M.
Thanks, Jenny
[filename,pathname] = uigetfile({'*.*';'*.txt';'*.csv';'*.xls'},'Select the data file file to import');
[~, ~, raw, dates] = xlsread(fullfile(pathname,filename),'Data','A3:M4508','',@convertSpreadsheetExcelDates);
0 Comments
Answers (1)
Fangjun Jiang
on 12 Feb 2016
If it is always to process all the data, would this work?
[~, ~, raw] = xlsread(fullfile(pathname,filename),'Data');
dates=convertSpreadsheetExcelDat(raw);
2 Comments
Fangjun Jiang
on 12 Feb 2016
xlsread(File,Sheet) allows not to provide the Range input argument. But the code wants to execute the convertSpreadsheetExcelDates() at the same time and it seems that the function requires the range input arguments.
I would suggest to separate the read of the Excel file and the processing of the data. Once the data is read from the Excel file, it is easy to get the size information of the data. You might have to re-write the convertSpreadsheetExcelDates() function. Run it separately after the data is read. Don't make it run through the call of xlsread().
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!