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

5 次查看(过去 30 天)
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?

采纳的回答

Kevin Holly
Kevin Holly 2023-2-15
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))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by