Clear Filters
Clear Filters

How to store data from App Designer to an Excel file, and continue to write after previous data (continuously) everytime the app has runned?

19 views (last 30 days)
I want to store data to Excel file, but it should not have deleted when app is closed, so one should be able to call the data back anytime wanted.
It'll be great if someone could give an idea or an example.
Thanks in advance.

Accepted Answer

Rohit on 4 Jan 2024
I understand that you want to store data to Excel file before closing the app.
For example, you can have the following callback function in your App Designer app which will get triggered to store the data.
function saveDataToExcel(app)
% Define the filename
filename = 'data.xlsx';
% Check if the file exists and read the existing data if it does
if isfile(filename)
existingData = readtable(filename);
existingData = table(); % Create an empty table if the file does not exist
% Create a table of new data - replace this with your actual data
% For example, let's say you have some edit fields in your app to collect data
newData = table(app.EditField1.Value, app.EditField2.Value, app.EditField3.Value, ...
'VariableNames', {'Column1', 'Column2', 'Column3'});
% Append the new data to the existing data
combinedData = [existingData; newData];
% Write the combined data back to the Excel file
writetable(combinedData, filename);
Make sure to replace app.EditField1.Value, app.EditField2.Value, and app.EditField3.Value with the actual properties of your app that contain the data you want to store.

More Answers (0)


Find more on Develop Apps Using App Designer 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!