I am trying to write a table to an excel file that is in the same path but am getting the error below. I tried most of what is suggested online but its still not working.
T=table(Sr,Plosskw,Qlosskw,angle,voltage);
T(:,1:5);
excel_file='33_bus_test_network_data.xlsx';
writetable(T,'NO_DG_IEEE33.xlsx','Sheet',6,'Range','A1');
this is the error
Unable to write to file 'NO_DG_IEEE33.xlsx'. Ensure the
file is a valid spreadsheet file and is not password
protected.
Error in loadflowofdistributionsystem (line 280)
writetable(T,'NO_DG_IEEE33.xlsx','Sheet',6,'Range','A1');

댓글 수: 5

Walter Roberson
Walter Roberson 2019년 9월 16일
Do you have write access to the current directory at the time you do the writetable?
sibabalo noludwwe
sibabalo noludwwe 2019년 9월 16일
I am not sure what you mean here do you mind explaining, all I know is that my excel file is not protected or requiring any password.
What is the output of
cd
?
sibabalo noludwwe
sibabalo noludwwe 2019년 9월 17일
Error using writetable (line 124)
Unable to write to file '33_bus_test_network_data.xlsx'. Ensure the file is a valid spreadsheet file and is not password protected.
Error in loadflowofdistributionsystem (line 239)
writetable(T,'33_bus_test_network_data.xlsx','Sheet',6,'Range','A1');
>> cd
C:\Users\Queen Siba\OneDrive - University of Cape Town\matlab\Graph Theory
this is the current directory which is also where the excel file is saved
Please show the output of
fileattrib 33_bus_test_network_data.xlsx
fileattrib .

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

답변 (2개)

sibabalo noludwwe
sibabalo noludwwe 2019년 9월 17일

0 개 추천

fileattrib 33_bus_test_network_data.xlsx
Name: 'C:\Users\Queen Siba\OneDrive - University of Cape Town\matlab\Graph Theory\September\33_bus_test_network_data.xlsx'
archive: 1
system: 0
hidden: 0
directory: 0
UserRead: 1
UserWrite: 1
UserExecute: 1
GroupRead: NaN
GroupWrite: NaN
GroupExecute: NaN
OtherRead: NaN
OtherWrite: NaN
OtherExecute: NaN
>> fileattrib
Name: 'C:\Users\Queen Siba\OneDrive - University of Cape Town\matlab\Graph Theory\September'
archive: 0
system: 0
hidden: 0
directory: 1
UserRead: 1
UserWrite: 1
UserExecute: 1
GroupRead: NaN
GroupWrite: NaN
GroupExecute: NaN
OtherRead: NaN
OtherWrite: NaN
OtherExecute: NaN

댓글 수: 1

Walter Roberson
Walter Roberson 2019년 9월 17일
Okay so the file exists and is writable, and you do have permission to write to the directory.
What this would tend to suggest is that the existing xlsx file is password protected.
A much less common but not impossible situation would be if the file system involved is completely full . Some filesystems support a limited number of files and cannot create new files if they have run out. But this is not likely for an NTFS file system (more likely for a FAT16 system.)

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

sibabalo noludwwe
sibabalo noludwwe 2019년 9월 17일

0 개 추천

so what are you suggesting am still confused

댓글 수: 1

Walter Roberson
Walter Roberson 2019년 9월 17일
Rename the existing 33_bus_test_network_data.xlsx to something else, and try the writematrix() again. If it works then you know that there was something about the content already in 33_bus_test_network_data.xlsx that was leading to the issue. Open the existing 33_bus_test_network_data.xlsx in Excel and see if it prompts for a password

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

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

태그

질문:

2019년 9월 16일

댓글:

2019년 9월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by