How to save the edited value inside the excel .xlsx file?

5 vues (au cours des 30 derniers jours)
Othman Alkandri
Othman Alkandri le 15 Fév 2023
Commenté : Othman Alkandri le 15 Fév 2023
Hello guys,
In my app, I am loading a .xlsx file, allowing the user to change some parameters. I figured out how to change the parameters in the app and store them in the app. Now I want the changed variables saved in excel as the following.
  1. Save should overwrite the .xlsx file.
  2. Save as should let the user save a new file of .xlsx.
Like when you write on a word doc, you can save your edited text in the same .doc file or a new .doc file. How can I do the code or a command to save and save as in .xlsxusing the buttons?

Réponse acceptée

Kevin Holly
Kevin Holly le 15 Fév 2023
Please see app attached.
I added filename as a property variable and then added the following:
For the Save callback, I added:
% Save
writetable(app.UITable.Data,fullfile(app.folder,app.filename))
For the Save as callback, I added:
[app.filename, app.folder] = uiputfile('*.xlsx');
writetable(app.UITable.Data,fullfile(app.folder,app.filename))

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by