Omitted reading the header row in excel files by redefining data range. Got the program to read each sheet in an excel file and store the row with max value for column 2. Thanks to Fangjun and all. these are my codes:
[File,Folder] = uigetfile('.xlsx', 'Select Excel XLSx File to be Process');
excel_data_range = 'A2:B' ;% self define, data is column A and B, 1st row header omitted, exl = actxserver ('Excel.Application'); % open com server
exlFile = exl.Workbooks.Open(fullfile(Folder,File)); [type,sheetname] = xlsfinfo(fullfile(Folder,File)); sheet_max = numel(sheetname); %Determine no. of sheets in current .xlsx file
for i=1:sheet_max
exlSheet = exlFile.Sheets.Item(cell2mat(sheetname(1,i)));
robj = exlSheet.Columns.End(4); % Find the end of the column
numrows = robj.row; % And determine what row it is
dat_range2 = [excel_data_range num2str(numrows)]; % Read to the last row
rngObj = exlSheet.Range(dat_range2);
exlData2 = rngObj.Value;
arr = cell2mat(exlData2);
%finding max in array, y is value, x is row of occurance
[x,y]=max(arr(:,2));
output(i,:)=arr(y,:);
end
end
toc
exl.Quit; exl.delete;