reading and writing the same Excel file in app designer

조회 수: 3 (최근 30일)
ZM
ZM 2020년 3월 27일
댓글: ZM 2020년 3월 28일
Hello;
I want to create a table that reads from an excel file, and after opening the table the user edit the table, and tthe editing should be saved in the same excel file
when the second time, the table is opend it must be updated.
my code:
function startupFcn(app)
Data = xlsread('edit_firststage2.xlsx');
-
-
-----------
function SendButtonPushed(app, event)
writetable(s1,'edit_firststage2.xlsx') % when I run the program it give rror in thiss line and it saying "you do not have permission"
Thank you in advance!

채택된 답변

Geoff Hayes
Geoff Hayes 2020년 3월 28일
ZM - check to see if you have permission to read and write to that file. If you do, then consider using readtable instead of xlsread to see if that somehow (?) allows you to better read and write to the same file (as xlsread isn't recommended to be used).

추가 답변 (1개)

ZM
ZM 2020년 3월 28일
편집: ZM 2020년 3월 28일
Thank you for your reply.
I do not have problem in reading the file, I have the problem in writing on this excel file. matlab do not have problem in writing on new excel file(first run) but when i repeat the run after modifying the data in my app, and i want to uploaded into same file, it gives this error.
Thank you
Zhina
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2020년 3월 28일
Zhina - did you try using readtable instead of xlsread? What happens if, for a new file, you create and write to it with writetable and then try this again? For example,
writetable(s1,'edit_firststage2.xlsx');
writetable(s1,'edit_firststage2.xlsx');
Does the second writetable fail? I realize that you are writing the same data to the same file, but this would be an interesting test to see if writing to pre-existing files is a problem OR is it just a problem when you try to read from a file (with xlsread) and then try to write to that same file?
ZM
ZM 2020년 3월 28일
thank you for your help, I used read table, but I have also to convert data that I read from excel file by using (table2cell) and converting it back after my calculation by(cell2table). and writing it to the excel file.
the reason for this is that app.UI Table in app deeesigner can take cell data.
Thank you

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by