uigetfile in Matlab Web App Server R2021a is not working

5 views (last 30 days)
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

Answers (1)

Chetan
Chetan on 10 Nov 2023
Edited: Chetan on 10 Nov 2023
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 !

Categories

Find more on MATLAB Web App Server in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!