This is a migrated thread and some comments may be shown as answers.

Trouble with ExcelExportFormatString

1 Answer 210 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 01 Sep 2011, 10:32 PM

When I am exporting from a radGridView to Excel the dateTime format was not working. I used a snipit of code I had found in this forum to format the column in the Excel document.

 

col.ExcelExportType = DisplayFormatType.Custom; 
col.ExcelExportFormatString = CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern;

This works for the most part but there is still an issue with the formatting. On my winform the date is displayed like
09/01/2011 4:30pm
The Excel doc then displays it as:
09/01/2001 16:30 tt

How can I format this to show up in the same manner?

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 07 Sep 2011, 09:46 AM
Hello Jack,

Thank you for your question.

The format specifier 'tt' in the ExcelExportFormatString property should be displayed as 'AM' or 'PM'. I confirm there is an issue in the Export to Excel functionality of RadGridView and this format specifier is not recognized. I added this issue to our PITS. We will address it in a future release. Your Telerik points have been updated.

You can modify the format string to work around the issue. The following code snippet displays the hours in the interval '0:23' without the 'AM' or 'PM' abbreviations:

col.ExcelExportFormatString = "MM/dd/yyyy H:mm";

I hope it helps.

Best regards,
Alexander
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
GridView
Asked by
Jack
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or