I have the code below in my function, however it doesn't write the data as I expected. instead of writing '2018-19 Auburn Women Basketball Home game as of 03/23/2019' all in cell A1 it puts each character in a different cell. This is happening with all of my string data.
lastGameDate = [stats(sRows, 1), stats(sRows, 2), stats(sRows, 3)];
xlsTitle = sprintf('2018-19 Auburn Women Basketball Home games as of %02.0f/%02.0f/%d',...
lastGameDate);
xlswrite(FILENAME, xlsTitle, OUTSPREADSHEET, 'A1')

 Réponse acceptée

Walter Roberson
Walter Roberson le 14 Avr 2019

0 votes

Try
xlswrite(FILENAME, {xlsTitle}, OUTSPREADSHEET, 'A1')
However if you are not using MS Windows or if you do not have Excel installed on MS Windows, then xlswrite cannot handle the task for you: without Excel on Windows, xlswrite is restricted to pure numeric values or to putting one character in each cell. If that situation applies to you then consider using writetable()

4 commentaires

Matthew Covington
Matthew Covington le 15 Avr 2019
Thank you! This works perfectly
Matthew Covington
Matthew Covington le 15 Avr 2019
Modifié(e) : Matthew Covington le 15 Avr 2019
Well, not all the way. Cell A1 does have the correct string. But also B1 has a 0 and C1 has a 1 and D1 has an 8 and so on. Still confused as to why it does this. Also my computer is on Microsoft 10 and I do have Excel installed, not sure why it's doing this
Walter Roberson
Walter Roberson le 15 Avr 2019
Is it possible those were already in the spreadsheet? Xlswrite does not remove content from cells it is not writing to.
Matthew Covington
Matthew Covington le 15 Avr 2019
That was the case, thanks for all the help

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by