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

4 ビュー (過去 30 日間)
Joseph Lesniak
Joseph Lesniak 2022 年 6 月 1 日
回答済み: Voss 2022 年 6 月 2 日
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 件のコメント
Voss
Voss 2022 年 6 月 1 日
"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?"
Joseph Lesniak
Joseph Lesniak 2022 年 6 月 2 日
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?

サインインしてコメントする。

回答 (1 件)

Voss
Voss 2022 年 6 月 2 日
"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);

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by