How to read & display an excel file (using a button to select the file)?
조회 수: 4 (최근 30일)
이전 댓글 표시
[file,path]= uigetfile({'*.*'},...
'select a file',app.filepath);
app.button1.Value= file;
t =xlsread('C:\Users\t.xlsx','sheet_3','A1:AA4');
I am trying this code, to read and display(in edit field) a selected file from a file explorer as soon as I click the 'Button1'.
I am able to display the file name, but the data in the file is not read (when I run the code and see in the command window).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/780463/image.png)
Kindly, let me know where am I going wrong?
댓글 수: 0
답변 (1개)
VBBV
2021년 10월 27일
%if true
[N TT R] =xlsread('C:\Users\t.xlsx','sheet_3','A1:AA4');% Try to change the out
It seems you have the excel file name and variable to which you are reading in workspace are same. Also check if the sheet with name sheet_3 exists in the file.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!