How to store data from App Designer to an Excel file, and continue to write after previous data (continuously) everytime the app has runned?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
piston_pim_offset
el 14 de Nov. de 2023
Respondida: Rohit
el 4 de En. de 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 comentarios
Respuesta aceptada
Rohit
el 4 de En. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!