How to store data from App Designer to an Excel file, and continue to write after previous data (continuously) everytime the app has runned?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
piston_pim_offset
le 14 Nov 2023
Réponse apportée : Rohit
le 4 Jan 2024
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.
0 commentaires
Réponse acceptée
Rohit
le 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);
else
existingData = table(); % Create an empty table if the file does not exist
end
% 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);
end
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.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!