MATLAB: Export Cell-Data to .xlsx [Saves less data]

cell2excelexport dataMATLABxlswritexlsx

Hello Everyone,
I am using following code to export Cell-data to .xlsx file.
filename='(AutoCheck7000).xlsx';
output = [header; Dataset];
xlswrite(filename,output); % Write to the new excel file.
Where as;
header is cell with 1*13 size
dataset is cell with 189*13 size
I have concentrated them using a variable output but xlswrite is only writing 2 header names instead of all names.
For instance;
the result is:
Whereas, the output-variable is as follows, so .xlsx should show all header names as well:
Any help would be appreciated 🙂
Best regard,s
Waqar Ali Memon

Best Answer

I recommend converting your cell-data to table and using function writetable().
filename='myExcelFile.xlsx';
myTable = cell2table(Dataset, 'VariableNames', header);
writetable(myTable, filename, 'WriteVariableNames', true);
There is a new function writecell() introduced in R2019a, which can write cell objects into Excel files directly. You may also want to try it. https://www.mathworks.com/help/matlab/ref/writecell.html
Related Question