How to set Column Type when using EPPlus

前端 未结 5 1005
予麋鹿
予麋鹿 2021-02-02 05:12

I\'m using EPPlus to generate Excel files, in DAL I\'m populating DataTable, filling data into table, and passing table to Presentation La

5条回答
  •  旧时难觅i
    2021-02-02 05:33

    You do need the DataTable column to have the right type but you also need to modify the column or cell's Style.Numberformat.Format property.

    Say you have an ExcelWorksheet named ws:

    ws.Column(1).Style.Numberformat.Format  = "yyyy-mm-dd"; 
    //OR "yyyy-mm-dd h:mm" if you want to include the time!
    

提交回复
热议问题