Azzera filtri
Azzera filtri

Write a row with mixed data to xlsx using xlswrite

2 visualizzazioni (ultimi 30 giorni)
Mauro Baldi
Mauro Baldi il 9 Dic 2015
Modificato: Kiran il 28 Dic 2015
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!

Risposte (2)

Kiran
Kiran il 28 Dic 2015
Modificato: Kiran il 28 Dic 2015
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.

Image Analyst
Image Analyst il 28 Dic 2015
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)
I tried it and it works. Now, read this.

Categorie

Scopri di più su Data Import and Analysis 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!

Translated by