Export data and Format Cells in Excel using Matlab using ActiveX

19 visualizzazioni (ultimi 30 giorni)
I'm exporting data to an excel file using ActiveX on Matlab and some of the data I'm exporting is in the format hh:mm:ss.sss. My data is supposed to be a quantity like 2 hours:45 minutes, not a time like 2PM, but excel automatically formats the cell and changes the numbers so that it's an AM/PM time. I can go into excel and change the cell formatting manually, but I would like this to be a one-step process because I'm processing lots of data. Is there a way to format individual cells to [hh:mm:ss.sss] using ActiveX while I'm writing to them or after I'm done writing data?

Risposte (1)

Guillaume
Guillaume il 20 Mar 2018
You can format individual or multiple cells at once with the NumberFormat property of your Range object. Something similar to:
yourrange.NumberFormat('hh:mm:ss.00'); %hh:mm:ss.00 is the excel format corresponding to matlab hh:mm:ss.sss

Community Treasure Hunt

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

Start Hunting!

Translated by