필터 지우기
필터 지우기

Why does uigetfile not open Excel files?

조회 수: 13 (최근 30일)
Jesse Walters
Jesse Walters 2022년 6월 2일
답변: Gagan Agarwal 2023년 9월 22일
Hi all,
I am using the following code to open and read data tables:
[FileName, PathName, FilterIndex] = uigetfile({'*.txt';'*.csv';'*.xls';'*.xlsx'},'File Selector');
T=readtable(strcat(PathName,FileName));
I have no issue opening .txt files, but I cannot select .xlsx files even after chosing this option via the file type selector (and even after choosing all file types!). What might cause this issue?
Edit: I selected the correct extension from the dropdown menu and it is still not possible to select Excel files. See below
Edit 2: I set the permissions to 'read and write' already, no change
  댓글 수: 3
Jesse Walters
Jesse Walters 2022년 6월 2일
It will not open any excel file in ANY folder
Jan
Jan 2022년 6월 2일
편집: Jan 2022년 6월 2일
By the way, prefer fullfile instead of strcat to concatenate parts of a path.
Please try:
cd('~')
[f, p] = uigetfile('*.*', 'File Selector')
When did this start? What has happend before?

댓글을 달려면 로그인하십시오.

답변 (1개)

Gagan Agarwal
Gagan Agarwal 2023년 9월 22일
Hi Jesse Walters,
I reproduced the issue you described using MATLAB R2023a on Mac OS and encountered the same. It appears that this problem is specific to the operating system rather than MATLAB itself, as the code worked correctly on Windows OS.
However, there is a workaround to open Excel using the 'uigetfile' function. You can refer to the following code snippet as an alternative method to open Excel using the 'uigetfile' function:
% uigetfile function is used to open a file dialog box, allowing the user to select a file.
[file,path] = uigetfile('*');
% fval is the variable in which the file is loaded.
[~,~,fval]=fileparts(file);
For more information you can refer to the following documentation link:
I hope this workaround proves helpful to you!

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by