C#如何复制你看到的excel的内容(例如:日期时间你看到的是12/31/2018,excel的内容是43465这样的数字)

C# How to copy the content of excel as you see (for example: date time as you see is 12/31/2018, excel content is a number like 43465)

我在将 excel 内容解析为日期时间类型时遇到问题。

在我的国家,只有两个 cultureinfo 可以使用:"vi-VN" (dd/MM/yyyy) 和 "us-US" (MM/dd/yyyy)。

对于我测试的某些情况,DateTime.Parse 和上面的 cultureinfo 都会抛出错误 "String is not recognized as a valid datetime"。

我想使用 DateTime.ParseExact 而不是上述方法。为此,我必须获得类似“12/31/2018”的字符串。但是当我使用 Epplus 时,它将单元格的内容读取为数字 43465。这样,我无法解析使用 DateTime.ParseExact.

这里有人知道如何阅读屏幕上显示的 excel 吗?

谢谢。

DateTime.FromOADate(Double) Method

var dateTime = DateTime.FromOADate(43465);