Writing cell of dates to Excel file
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
John Cruce
el 2 de Abr. de 2023
Comentada: Adam Drake
el 13 de Abr. de 2023
I have a cell of dates (characters - 4700x1 cell) formatted as mm/dd/yyyy. When I attempt to write to an Excel file using xlswrite, it places all the dates in one cell, with line breaks for each backslash. How might I get an Excel file with each date as a separate row within the same column?
0 comentarios
Respuesta aceptada
Adam Drake
el 2 de Abr. de 2023
Recommend using writecell and readcell instead. If you can't I will reinvestigate. Ex:
Y = [2014;2013;2012];
M = [01;02;03];
D = [31;30;31];
t = datetime(Y,M,D,'Format','MM/dd/yyyy');
datecells = cellstr(t);
filename = 'text.xlsx';
sheet = 1;
xlRange = 'B1';
writecell(datecells,filename,'Sheet',sheet,'Range',xlRange)
readcell(filename,'Sheet',sheet,'Range',xlRange)
2 comentarios
Peter Perkins
el 5 de Abr. de 2023
There's no need to create that cell array, at least in recent versions of MATLAB:
writematrix(t,filename,'Sheet',sheet,'Range',xlRange)
Adam Drake
el 13 de Abr. de 2023
The question was that they already had a cell of dates. I was just providing an example of using writecell. Everything before that was just to set that up.
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!