How do I create an app that I can import Excel data into?

I want to use the app designer to make an app that provides an easy way to create graphs and tables for Excel data but I do not know how to go about inputting the files. Is there any way that an aplication can take you to the file explorer so you could choose what files to work with? If not, what would be the best way to input Excel matrices into an app?

2 Comments

"Is there any way that an aplication can take you to the file explorer so you could choose what files to work with?"
"what would be the best way to input Excel matrices into an app?"
Thanks I got it to work, but does the file I want to import always have to be in the MATLAB folder or in the folder the designed App is downloaded in?

Sign in to comment.

Answers (1)

"does the file I want to import always have to be in [a particular folder]"
No.
uigetfile lets the user select a file in any folder.
readmatrix/readtable allow you to specify full paths to files.
Example:
[file_name,path_name] = uigetfile('*.xlsx','Select an Excel File');
if ~ischar(file_name)
% if no file was selected (e.g., Cancel was clicked or file dialog
% was closed without making a selection), file_name and path_name
% are 0 -> don't do anything in that case
return
end
% construct full-path file name, e.g., 'C:\Users\JL\Documents\file1.xlsx'
full_file_name = fullfile(path_name,file_name);
% call the reading function on the file:
data = readtable(full_file_name);

Products

Release

R2022a

Asked:

on 1 Jun 2022

Answered:

on 2 Jun 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!