What is the best way to write a duration type to an Excel file?

3 views (last 30 days)
I have an array of duration type. I want to write it to Excel and then use it as a time in excel. Is there a recommended way to get this effect?
d = duration([24;25],[0;10],[10;17]);
xlswrite('Example.xlsb', d);
If you write the d to Excel, the spreadsheet will not contain any version of the duration information in d.

Accepted Answer

Lars Abrahamsson
Lars Abrahamsson on 23 Dec 2020
What about the other function to create Excel files from tables?
writetable
  1 Comment
Jason Nicholson
Jason Nicholson on 28 Dec 2020
Yes, this works in 2020b. I am not sure it works in the 2016b or 2016a that I was working in at the time.
d = duration([24;25],[0;10],[10;17]);
writetable(table(d),"example.xlsx")

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 14 Jan 2016
Edited: Walter Roberson on 23 Dec 2020
So write a serial date number which is the duration in days (and fraction of a day). You may wish to go in with ActiveX and apply a time format to the cell.

Products

Community Treasure Hunt

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

Start Hunting!