Why `WriteMode` isn't working while appending data to xlsx?

조회 수: 16 (최근 30일)
Deepa Maheshvare
Deepa Maheshvare 2020년 5월 20일
편집: Anthony Phipps 2020년 10월 18일
I'm doing the following
excelFilename = 'someFile.xlsx';
structFieldnames = fieldnames(myStruct); % <--- where myStruct is your struct of data
for k = 1:length(structFieldnames)
fieldname = structFieldnames{k};
writecell(myheaderstruct.(fieldname), excelFilename, 'Sheet', sprintf('%s_matlab', fieldname)); % add header
writematrix(myStruct.(fieldname), excelFilename, 'Sheet', sprintf('%s_matlab', fieldname),'WriteMode','append');
end
Error:
Invalid parameter name: WriteMode.
If 'WriteMode','append' isn't included, the header is overwritten.
Could someone suggest why `WriteMode` isn't working here?
This is a follow up to my previous post here.
This
writematrix(data.(fieldname), excelFilename,'-append', 'Sheet', sprintf('%s_simgraph', fieldname));
also doesn't work.
Wrong number of arguments. A filename must be provided when supplying additional parameters, and each parameter name must be followed by a value.
I'm using 2109b.

채택된 답변

Walter Roberson
Walter Roberson 2020년 5월 20일
  댓글 수: 3
Walter Roberson
Walter Roberson 2020년 5월 20일
Read the existing sheet as cell. Pad it or the new data to have the same number of columns. Put the two parts together. Write out to the sheet.
Anthony Phipps
Anthony Phipps 2020년 10월 18일
편집: Anthony Phipps 2020년 10월 18일
This post is a life saver - thanks

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by