Effacer les filtres
Effacer les filtres

UIGETFILE start in another directory AND choose two default file types

38 vues (au cours des 30 derniers jours)
Adriano
Adriano le 18 Août 2011
Commenté : PL.R le 21 Jan 2021
I am using UIGETFILE to choose Excel files, with .xls AND .xlsx extension. Also, I want UIGETFILE to start in another directory. I already looked at the documentation and in this post. I know I would have to use something like this:
uigetfile([pwd '\folder1\*.xls'], 'Select file');
However, that would only allow me to select .xls files. I want it to allow me to select .xls files AND .xlsx files.
How can I do this?

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 18 Août 2011
uigetfile(fullfile(pwd,'folder1','*.xls;*.xlsx'),'select file')
  2 commentaires
Adriano
Adriano le 18 Août 2011
Thanks, it worked. This option should be explicitly stated in the documentation.
Fangjun Jiang
Fangjun Jiang le 18 Août 2011
I agree! It took me a while to figure it out.

Connectez-vous pour commenter.

Plus de réponses (1)

William Frane
William Frane le 20 Jan 2012
There's a slightly more flexible way to accomplish this:
uigetfile({'*.txt;*.doc' 'Text file or Word document';'*.txt' 'Text file'; '*.doc' 'Word document'},'Select a file','C:\');
This makes use of uigetfile's optional DefaultName argument to specify the starting path. Since FilterSpec isn't being used to provide the path, it can be a cell array of strings, which enables the use of custom file type descriptions (something that's not possible if FilterSpec is a single string as in the example above).
  1 commentaire
PL.R
PL.R le 21 Jan 2021
I was looking for this for a while. Tank you so much. Should be the accepted answer

Connectez-vous pour commenter.

Catégories

En savoir plus sur Text Data Preparation dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by