How to make correct date format when writing data to Excel

后端 未结 10 1908
[愿得一人]
[愿得一人] 2020-11-30 04:56

Iam exporting a DataTable to an Excel-file using office interop. The problem is, that Excel does not recognize dates as such, but instead it displays numbers. In another cas

10条回答
  •  自闭症患者
    2020-11-30 05:07

    This worked for me:

    hoja_trabajo.Cells[i + 2, j + 1] = fecha.ToString("dd-MMM-yyyy").Replace(".", "");
    

提交回复
热议问题