Export data and Format Cells in Excel using Matlab using ActiveX

19 Ansichten (letzte 30 Tage)
India Aitkenhead
India Aitkenhead am 19 Mär. 2018
Beantwortet: Guillaume am 20 Mär. 2018
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?

Antworten (1)

Guillaume
Guillaume am 20 Mär. 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