Why do I get the error 'Ensure the file is a valid spreadsheet file and is not password protected.'?
30 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!