使用NPOI读取row.GetCell(9).ToString() excel文件的带日期时间数据,结果为1/19/22 8:26:00
C#无法正确识别为datetime格式
解决方法:
row.GetCell(10).DateCellValue.ToString();
或者网友方案:
C# NPOI读取excel日期格式的问题(2020-08-15 变成 12-5月-2020了) - 包子789654 - 博客园
string strDeliveryTime = null;
if (currentRow.GetCell(dicData["需求日期"]).CellType == CellType.Numeric)
{
strDeliveryTime = Convert.ToDateTime(currentRow.GetCell(dicData["需求日期"]).DateCellValue)
.ToString("yyyy-MM-dd");
}
else
{
strDeliveryTime = currentRow.GetCell(dicData["需求日期"]).ToString();
}