Save Structure to a new excel sheet
Ältere Kommentare anzeigen
How do I save a structure containing one numeric field and one string field in a particular sheet in excel?
Antworten (1)
Image Analyst
am 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.
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!