Trouble with ExcelExportFormatString

2 posts, 0 answers
  1. Jack
    Jack avatar
    25 posts
    Member since:
    Feb 2011

    Posted 01 Sep 2011 Link to this post

    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?

  2. Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 07 Sep 2011 Link to this post

    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 >>

Back to Top