使用下面代码导出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();
}
{
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Accounts");
ws.Cells["A1"].LoadFromDataTable(dt, true);
pck.Save();
}
//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();