Reputation: 24739
I'm using excel interop to build reports. I have the string "April 8, 2013" as a string and I'm assigning it to a cell as such (where oSheet is an Excel._Worksheet
and it's VB.Net):
oSheet.Cells(5, 2) = dateStr;
Nothing is modifying the NumberFormat
or any other properties for that particular cell but what is being displayed when I open the output xlsx file is "8-Apr-13".
How can I force excel to just display the string without any additional formatting that might change the text?
Upvotes: 1
Views: 629
Reputation: 6698
To force Excel to treat a date, or any non-textual data, as text, and thus not changing it's format automatically, you can use either of the following two methods:
'08/01/2013
range.NumberFormat = "@";
Upvotes: 1