12/09/2009

How to set date time as text to a excel in DD/MM/YYYY format using ASP.NET ?

Did you ever try to set a date as text to Excel cell using asp.net ? I had this interesting problem today. The date that I have been passing from my code is something like this '02/06/2009' (dd/mm/yyyy) .But When I check the Excel it appeared as '06/02/2009' (mm/dd/yyyy) . Dates with date > 12 will appear correctly in the excel . I tried by setting the format of cells to dd/mm/yyyy but no luck. So How will we achieve it ?

Solution :

To avoid this problem all you need to do is append a single quote (') before your date . i.e '02/06/2009 should be set as text to excel and you will see the date in correct format.

For more solutions to day to day ASP.NET problems , Subscribe here or click here to get updates via email

3 comments:

Hogan scarpe are suitable for trail running. Americans have been adventurous all along is only endorsed by shoes that aim to safeguard lives of trail runners if Hogan scarpe uomo are anything to go by. Hogan scarpe donna is in the forefront of innovative technologies that eliminate fear element from trail runners' minds that otherwise are constantly haunted by the rough mountainous terrains, the forest route hogan donna run through without being able to concentrate on competition.

Excellent, thanks for the tutorial excel it's a very useful tool but very difficult to use ... thanks

Post a Comment