Why `WriteMode` isn't working while appending data to xlsx?
18 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Deepa Maheshvare
il 20 Mag 2020
Modificato: Anthony Phipps
il 18 Ott 2020
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
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.
0 Commenti
Risposta accettata
Walter Roberson
il 20 Mag 2020
Writemode is a new option as of R2020a.
3 Commenti
Walter Roberson
il 20 Mag 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
il 18 Ott 2020
Modificato: Anthony Phipps
il 18 Ott 2020
This post is a life saver - thanks
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!