xlsread and password protected Excel files
Ältere Kommentare anzeigen
There is nothing in the xlsread help file about passwords & the xlsprotect fuction (file exchange) does not work (all it does is hang & you have to shift to the Excel window to enter your password).
Does anybody know how to do this properly from a Matlab file?
1 Kommentar
Ehtisham
am 28 Jun. 2021
Go and download this code. It will protect the excel file with password. The files won't remain editable unless you unprotect them by providing the password.
Akzeptierte Antwort
Weitere Antworten (3)
Joseph Cheng
am 11 Sep. 2014
you would have to use activeX. Since getting data from excel using activeX is documented fairly well i'll leave here how to open a file with the password.
[fname pname]=uigetfile('protected.xlsx');
password = 'password';
xlsAPP = actxserver('excel.application');
xlsWB = xlsAPP.Workbooks;
xlsFile = xlsWB.Open([pname fname],[],false,[],password)
xlsFile.Visible = 1;
where i hard coded the password with password and my test xls file was protected.xlsx.
1 Kommentar
Joseph Cheng
am 11 Sep. 2014
there is a function on the file exchange called xlsprotect which looks to be able to unprotect and protect the file again but that maybe problematic in a security standpoint (the xls files were protected for some reason) and if program crash or hangup the reprotect wouldn't occur.
Les
am 11 Sep. 2014
0 Stimmen
Les
am 11 Sep. 2014
0 Stimmen
Kategorien
Mehr zu Use COM Objects in MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!