Why do I get the error 'Ensure the file is a valid spreadsheet file and is not password protected.'?

19 ビュー (過去 30 日間)
Hannah
Hannah 2021 年 8 月 17 日
コメント済み: Hannah 2021 年 8 月 17 日
I want to create an excel file called 'Results' in the same directory as my matlab file. This is the code I wrote so far:
Result_File='Results.xlsx'; %save result into this excel file
% [a loop is here to obtain 'T']
fid = fopen(Result_File,'w');
writetable(T,Result_File)
when I run it, I get the error:
Error using EXP2_Ver12_Evaluation_of_Meteonorm_simulation (line 105)
Unable to write to file
'\\data-be\data-ti-2019\eit\50_Labore\T016-Photovoltaik_1\06_Projekte\02_Aktiv\2019_Schenker_Storen\DOCS_Hannah\Experiment2\04_Evaluation_of_Meteonorm_simulation\Results.xlsx'.
Ensure the file is a valid spreadsheet file and is not password protected.
I dont understrand how it could be passwprd protected or not valid because my script creates the file that I am writing into.

採用された回答

Johannes Hougaard
Johannes Hougaard 2021 年 8 月 17 日
Because you make and open the (empty) file with the fopen call but don't use the file identifier for the writetable (which you shouldn't do).
make sure you have all file identifiers closed (exit MATLAB or call fclose all), delete the Results.xlsx file and re-run the code without fopen
Result_File='Results.xlsx'; %save result into this excel file
% [a loop is here to obtain 'T']
writetable(T,Result_File)

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by