EPPlus导出EXCEL文件日期怎么处理?

liushiying18 2019-11-01 07:56:52
使用下面代码导出EXCEL文件后,文件日期部分为数字,如何将日期设置成日期格式啊

DirectoryInfo outputDir = new DirectoryInfo("d:\abc\");

FileInfo newFile = new FileInfo(outputDir.FullName + strTargetExcel + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx");

using (ExcelPackage pck = new ExcelPackage(newFile))
{
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Accounts");
ws.Cells["A1"].LoadFromDataTable(dt, true);
pck.Save();
}
...全文
448 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Hello World, 2019-11-01
  • 打赏
  • 举报
回复
官方示例文档有这方面的代码:
            //Load the datatable and set the number formats...
wsDt.Cells["A1"].LoadFromDataTable(dt, true, TableStyles.Medium9);
wsDt.Cells[2, 2, dt.Rows.Count + 1, 2].Style.Numberformat.Format = "#,##0";
wsDt.Cells[2, 3, dt.Rows.Count + 1, 4].Style.Numberformat.Format = "mm-dd-yy";
wsDt.Cells[wsDt.Dimension.Address].AutoFitColumns();

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧