Write a row with mixed data to xlsx using xlswrite
3 次查看(过去 30 天)
显示 更早的评论
I need to create a spreadsheet with mixed data (one number, one string, one number). Even though I convert a row into a string, the final output is an empty spreadsheet. Here is an example of code summarizing my problem:
id = 1
folder = cellstr('folder')
pos = 3
oneRow = {num2cell(id), folder, num2cell(pos)}
xlswrite('Prova.xlsx', oneRow)
The row "oneRow" does not appear on the output file "Prova.xlsx".
How can I solve this problem?
Thank you!
0 个评论
回答(2 个)
Kiran
2015-12-28
编辑:Kiran
2015-12-28
Hi,
Input matrix to "xlswrite" cannot have nested cell array that is cells inside cell array. One workaround to your issue could be making array of individual cells like:
xlswrite('Prova.xlsx',[num2cell(id),cellstr('folder'),num2cell(pos)]);
This worked at my end.
0 个评论
Image Analyst
2015-12-28
You have cells inside of cells. That won't work. You need numbers and strings inside the cells. Try it this way:
id = 1
folder = 'folder'
pos = 3
oneRow = {id, folder, pos}
xlswrite('Prova.xlsx', oneRow)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!