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

28 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 20 de Mayo de 2020
  3 comentarios
Walter Roberson
Walter Roberson el 20 de Mayo de 2020
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 el 18 de Oct. de 2020
Editada: Anthony Phipps el 18 de Oct. de 2020
This post is a life saver - thanks

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by