Save Structure to a new excel sheet
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How do I save a structure containing one numeric field and one string field in a particular sheet in excel?
0 commentaires
Réponses (1)
Image Analyst
le 15 Nov 2021
You can store the values in a cell array and then use xlswrite(). Untested code:
ca = cell(2, 2);
ca{1, 1} = 'My Number';
ca{1, 2} = str.NumericField; % Put the number into row 1, column 2.
ca{2, 2} = {str.StringField}; % Put the string's row header into row 2, column 1.
ca{2, 2} = str.stringField; % Put the string into row 2, column2.
xlswrite(xlFullFileName, ca, 'Sheet 1', 'A1')
P.S. If
ca{2, 2} = {str.StringField};
doesn't work, try
ca{2, 2} = str.StringField;
but sometimes if you don't put the string into a cell, it just puts one letter of your string in different cells in Excel.
0 commentaires
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!