How to open an excel file from the listbox(having a number of excel files) in gui(GUIDE)?
3 次查看(过去 30 天)
显示 更早的评论
Hi, I have made a gui(having a pushbutton and a listbox).I am using the pushbutton to select some excel files from a directory(in My computer)and showing them in listbox.Now I want to open excel files from the listbox by clicking the respective file.Please tell me how to use 'winopen' function and where to use it(under callback function of listbox or under pushbutton callback function(here I have written the code for opening the window to select files and then displaying them in listbox).Thanks for your help.
0 个评论
回答(2 个)
Image Analyst
2014-10-9
% Get a list of indexes in the listbox that the user has selected.
Selected = get(handles.lstExcelFiles, 'Value');
% If more than one is selected, bail out.
if length(Selected) > 1
return;
end
% If you get to here, exactly 1 is selected.
% Now, get a list of all the items in the listbox.
ListOfFileNames = get(handles.lstExcelFiles, 'string');
% Get the name of the one particular file that has been selected.
baseFileName = strcat(cell2mat(ListOfFileNames(Selected)));
% Get the full file name by prepending the folder where the files live.
excelFullFileName= fullfile(folder, baseFileName);
% Open file in Excel.
winopen(excelFullFileName);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!