フィルターのクリア

How to import all sheets of excel file with "UIgetfile" option?

16 ビュー (過去 30 日間)
taimour sadiq
taimour sadiq 2021 年 2 月 19 日
コメント済み: taimour sadiq 2021 年 2 月 19 日
i m writing a code that fetch a excell file including all sheets and store that data in a Variable etc. What I've managed to do so far is i have written two codes, my first code is working but extracting only first sheet of any file...
filter = {'*.xlsx';'*.csv'};
[xlsfile,paht2xls] = uigetfile(filter,'Import-Daten');
FileData = xlsread(fullfile(paht2xls,xlsfile));
my second code extract all sheets of excel file but i m unable to integrate "uigetfile" in this code...
[~,sheet_name] = xlsfinfo('Data.xlsx');
for k = 1:numel(sheet_name)
data{k} = xlsread('Data.xlsx',sheet_name{k});
end
Kindly Guide either first code should extract all sheets of any excel file or second code which is extracting all sheets should work with "uigetfile" instead of specifying file name.... Thanks

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 2 月 19 日
Use uigetfile to select the file. Then use that name in your second code to import all the sheets. Maybe something like this (untested)
[xlsfile,paht2xls] = uigetfile(filter,'Import-Daten');
[~,sheet_name] = xlsfinfo(fullfile(paht2xls,xlsfile));
for k = 1:numel(sheet_name)
data{k} = xlsread(fullfile(paht2xls,xlsfile),sheet_name{k});
end
  3 件のコメント
Cris LaPierre
Cris LaPierre 2021 年 2 月 19 日
If you are going to immediately turn your table into an array, you should use readmatrix instead of readtable.
taimour sadiq
taimour sadiq 2021 年 2 月 19 日
Thanks.. Got it :-)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by