Click here to Skip to main content
15,936,903 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,


How to set excel date format, while exporting a grid data to Excel
Posted
Updated 7-Feb-11 23:24pm
v4
Comments
TimGameDev 8-Feb-11 5:23am    
It's unclear for me what exactly you're trying to do from your question.
If you export data from grid to somewhere you can use String.Format method to format cell value. http://msdn.microsoft.com/ru-ru/library/system.string.format.aspx

If it doesn't help you please improve your question with more information.
NITHIN INDIA 9-Feb-11 6:02am    
Hello,

while Exporting my grid error on date format
my grid date format is M/D/YYYY and my system Format is DD-MM-YYYY

Collapse
/*
my grid eg:

Start Date End Date
1/1/2011 12/31/2011

exported to Excel shows like

Start Date End Date
01-01-2011 12/31/2011

*/
Pls Help me

Do you mean you want to format existing data to an excel format PRIOR to exporting?

If so just format to any date format that suits you, as excel will pick up the format automatically.

Or, do you mean you want to alter the format After is has been sent to excel?
If so then a simple macro will do the trick in changing it.

Your question is not clear, give more details of the requirement for a more succinct answer.
 
Share this answer
 
What is 'EXCEL Date Format'?

Could you provide a link or otherwise explain?
 
Share this answer
 
Comments
TimGameDev 8-Feb-11 5:25am    
nice answer with two questions =)
NITHIN INDIA 8-Feb-11 5:48am    
podey
Henry Minute 8-Feb-11 6:50am    
Does that have any meaning?

Could you please provide a link or otherwise explain?
I think you are asking this...

Exporting Grid view or data Grid to Excel ,Formatting cells with style sheet mso-number-format[^]

Export GridView data to Excel,Word, & Text file[^]

My suggestion is clarify your question little bit more if possible include your code, etc., in your question.

cheers.
 
Share this answer
 
Comments
NITHIN INDIA 9-Feb-11 6:01am    
Hello,

while Exporting my grid error on date format
my grid date format is M/D/YYYY and my system Format is DD-MM-YYYY

Collapse
/*
my grid eg:

Start Date End Date
1/1/2011 12/31/2011

exported to Excel shows like

Start Date End Date
01-01-2011 12/31/2011

*/
Pls Help me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900