
When using a writetable to write a table file containing data in datetime format to Excel, the saved datetime data in Excel is not in the same format as the datetime data
5 ビュー (過去 30 日間)
古いコメントを表示
The table data is as follows:

Use the following writetable function code to save data to Excel,the exported result is shown in the following figure:

The time display is incomplete.
How to set the exported time format to be the same as the original data?
writetable(T, filePath);
0 件のコメント
採用された回答
Cris LaPierre
2025 年 4 月 9 日
編集済み: Cris LaPierre
2025 年 4 月 9 日
For Excel files, writetable writes table variables containing datetime arrays as Excel dates. The time data is still all there, but Excel applies its own formatting to dates. You will need to set the display format in Excel using their settings to see the same details.

2 件のコメント
Cris LaPierre
2025 年 4 月 10 日
Not using writetable, especially if you are creating a new file. There is probably a way to do it using activeX commands. You may be able to modify the code shared in this answer: https://www.mathworks.com/matlabcentral/answers/2140571-how-to-format-cell-font-size-font-color-and-alignment-in-excel-from-matlab-gui-program
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!