Issue with MATLAB .exe seeing data in excel as stagnant data when I need it to be able to read with each run of the .exe

1 view (last 30 days)
I have a program that uses XLSread and XLSwrite.
The program takes in some excel data from an excel file, we do some math, then we output to the excel file and open it up for the user to see the output.
This program works perfect in the IDE, but when I make an .EXE and try the program that way, whatever the last data I had in the excel run in the IDE, is ALWAYS the output for the .exe now. Even when I change the data in the excel file and rerun.
How would I go about making this dynamic? Or have the program read in the new data from the excel file with each subsequent run?
example:
******************************************************************************
% read in some data
[num,txt,raw] = xlsread('excelFile','REPORT');
% do some math
x= 5 * num (1)
%export it back to excel file
xlswrite('excelFile',matrix,'sheet1')
%open the file up for the user
winopen('excelFile')
******************************************************************************
any and all help is greatly aprecaited!
,Billy

Answers (1)

Walter Roberson
Walter Roberson on 28 Jun 2023
read about ctfroot which is the directory that the code will be executing in, and the location that your named files will have been copied to.
The executable will NOT be running in the user's home directory. You will need to figure out the user directory by looking at windows environment variables. Caution: some of the folders named in the environment variables do not have drive letter, which is a different environment variable
  1 Comment
Billy
Billy on 29 Jun 2023
root = ctfroot returns the name of the folder where the deployable archive for the application is expanded.
Use this function to access any file that the user would have included in their project (excluding the ones in the packaging folder).
What if the excel file is in fact in the pakcaged folder ? And I still cant get the data to update if I change the data in the excel file its suppose to be looking at with each run of the .exe

Sign in to comment.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!