This project has moved and is read-only. For the latest updates, please go here.

Get value as seen in excel, not value in cell

Oct 22, 2013 at 7:59 PM
Here's a problem I found:
I just need to get the value as seen in excel, not the real value in that cell.
For example:
I have a column of cells with a custom style of date.
What I see when I open excel is: 11/07/13
When I get this value on EPPlus, they return me something like: 44211.
What I need is a string with "11/07/13", not the numbers/things that are in the cell itself.

In INTEROP, we can use .Value2 to get this.

Thank you guys!
Oct 23, 2013 at 3:18 PM
I am having the same issue. You can use

DateTime.FromOADate(cell.NumericCellValue).ToShortDateString();

but this relies on knowing the cell's real value is actually a date and not a number. I am yet to find a way of determining if the real value is actually a date or not.

If we could get the value as seen in excel then this would no longer be a problem.
Oct 23, 2013 at 4:02 PM
Exactly! Sometimes we just wanna get the data to put in another format, or make things with only the value we see...
Hope someone can see this and tell if there is a way to do it, or if they can implement it!
Oct 29, 2013 at 12:21 PM
I have found by doing cell.ToString() will return value as it is seen in excel including the formatting. Hope this helps.