- Open your App Designer app in MATLAB.
- Click on the "Apps" tab in the MATLAB toolstrip and select "Add-Ons > Manage Add-Ons".
- In the "Manage Add-Ons" dialog box, click on the "Installed" tab and locate the "MATLAB Compiler" product.
- Click the "Settings" button next to the "MATLAB Compiler" product to open the "Compiler Settings" dialog box.
- In the "Compiler Settings" dialog box, go to the "Files and Folders" section and select the "Required Files" tab.
- Click the "+" button to add your Excel file to the list of required files.
- In the "Include file" dialog box, navigate to the location of your Excel file and select it.
- Click "Open" to add the file to the list of required files.
Issue with MATLAB not finding my excel file even though its in the same folder as the .exe
11 views (last 30 days)
Show older comments
I have a script that takes in data from an excel file. It works fine it seems in the IDE, but when I complie the code as an app for deployment
MATLAB no longer can find the excel file event though its in the same folder as my .exe
% read in excel data
[num,txt,raw] = xlsread('XXX.xlsx','SHEET1');
[num1,txt1,raw1]=xlsread('XXX.xlsx', 'SHEET1');
Can anyone help me out?
Thank you in advance,
Billy
0 Comments
Accepted Answer
Satwik
on 22 Jun 2023
When you deploy your MATLAB code as an executable app, you need to make sure that all required files, such as the Excel file in your case, are included in the app package and accessible by the deployed app.
To include your Excel file in the app package, you can add it to the "Required Files" section in the App Designer by following these steps:
Now, when you deploy your app using the MATLAB Compiler, the Excel file will be included in the app package and accessible by the deployed app.
In your code, you can access the Excel file using the mfilename function to get the full path to the directory where the executable app is located, and then use the fullfile function to build the full path to the Excel file, like for example :
% get the full path to the directory where the executable is located
appDir = fileparts(mfilename('fullpath'));
% build the full path to the Excel file
excelFile = fullfile(appDir, 'XXX.xlsx');
% read in excel data
[num,txt,raw] = xlsread(excelFile, 'SHEET1');
[num1,txt1,raw1] = xlsread(excelFile, 'SHEET1');
More Answers (1)
See Also
Categories
Find more on Spreadsheets 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!