uigetfile in Matlab Web App Server R2021a is not working

조회 수: 2 (최근 30일)
Christian Scholz
Christian Scholz 2022년 2월 10일
편집: Chetan 2023년 11월 10일
Hello Matlab Community,
We developed a web app where the user uploads an Excel file, imports the data and calculations are being dispayed. This used to work fine for the last couple of month. We used uigetfile and xlsread in a separate m.file.
We are now compiling with version 2021a and the WebAppServer running on 2021a.
After executing the uigetfile the Web App is stuck within the m.file with our xlsreach commands.
Code in the App Designer:
function UploadExcelsheetButtonPushed(app, event)
app.UploadExcelsheetButton.Enable = 'off';
[file, path, ~] = uigetfile('*.xlsx');
app.filename = [path file];
Location = app.filename;
run("Test.m")
app.OperationTimeEditField.Value = Inputs.Operation_time;
drawnow;
app.UploadExcelsheetButton.Enable = 'on';
end
Code in Test.m:
Inputs.Operation_time = xlsread(Location,'B1:B1');
EDIT: I have tried to do it with readtable and get the same error
Note: Interestingly it works when the file is in .csv format. Same code for xlsx files will not work.
Can you please tell us what u think went wrong? It used to work before.
Thank you and BR,
Christian

답변 (1개)

Chetan
Chetan 2023년 11월 10일
편집: Chetan 2023년 11월 10일
I understand that you developed a MATLAB web app where users can upload Excel files for data calculations. However, the app gets stuck with 'uigetfile' in the .m file
Here are some of the possible workaround to fix this issue:
  • 'xlsread' isn't recommended for web apps. Use 'readtable' or 'readmatrix' instead.
Here's your modified code:
Inputs.Operation_time = readmatrix(Location,'Range','B1:B1');
Adjust the 'Range' argument as needed.
Refer to the following MathWorks Documentation regarding the usage of the function:
Hope this Helps !

카테고리

Help CenterFile Exchange에서 MATLAB Web App Server에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by