MATLAB Answers

Matlab executable does not open excel file

15 ビュー (過去 30 日間)
Hi All,
I created a matlab executable that should open an excel file with couple of sheets, read info from there and use the info in the code in order to elaborate the final information that I need.
When I run the code in Matlab it works totally fine - it opens the excel file, reads and keep working.
When I run the executable created with ApplicationCompiler in the "for_testing" folder that is generated, when I select the .xlsx file that the code needs to read it pops up an error message saying:
"Unable to open file 'vehicle.xlsx' as workbook. Check that the file exists, read access is available, and the file is a valid spreadsheet file."
Code-wise speaking, I am creating a GUI:
1- in the main code, below the GUI function "OpeningFcn", I am recalling a .m file (included in the application compiler list).
2- this .m file contains the following code:
[filename1,pathname1] = uigetfile('*.xlsx','Select VEHICLE PARAMETERS file');
table = readtable(filename1,'Sheet','names');
Since I am coding on R2019a, I am not using xlsread since on the guide is not reccomended.
Thanks in advance

  0 件のコメント

Sign in to comment.


Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2020 年 4 月 17 日
Hello Antonio,
While compiling the executable application, include the Excel file along too. Use the '-a' flag for this. Make sure that the Excel exists and has the correct path available to the compiled program.
These discussions on the MATLAB Answers forum might provide you better context:
  • Including data file with standalone executable: LINK
  • Using Excel data with standalone executable: LINK
  • Read & Write data to Excel sheet with a standalone executable: LINK
Hope this helps!

  2 件のコメント

Antonio Carlo Caruso
Antonio Carlo Caruso 2020 年 4 月 17 日
Hi Vinai,
Thank you for your answer!!
I managed to make it work:
- [filename1,pathname1] = uigetfile('*.xlsx','Select VEHICLE PARAMETERS file');
- table = readtable(filename1,'Sheet','names');
in the readtable function I was specifing just the name of the file excel and no path, for this reason the code was not able to open the file.
This is how the code should be!
- [filename1,pathname1] = uigetfile('*.xlsx','Select VEHICLE PARAMETERS file');
- new_name1 = [pathname1 filename1];
- table = readtable(new_name1,'Sheet','names');
I found out this while trying to load a mat file inside the GUI. I was getting the same issue.
It was very helpful logging the errors while running the executable (found it in one of the link that you shared).
Thank you very much for your support and inspiration!
Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2020 年 4 月 17 日
Glad to know that you made it work, Antonio!
Stay safe!

Sign in to comment.

その他の回答 (0 件)




Translated by