Last Updated: 22 Feb 2017 09:00 by ADMIN
Dess | Tech Support Engineer, Principal
Created on: 07 Apr 2016 08:18
Category: GridView
Type: Bug Report
FIX. RadGridView - SpreadExport does not respect the AM/PM time part with custom date format
To reproduce:

public class Item
    public int Id { get; set; }

    public string Name { get; set; }

    public DateTime Date { get; set; }

    public Item(int id, string name, DateTime date)
        this.Id = id;
        this.Name = name;
        this.Date = date;
public Form1()
    List<Item> items = new List<Item>();
    for (int i = 0; i < 10; i++)
        items.Add(new Item(i,"Item" + i,DateTime.Now.AddHours(i)));
    this.radGridView1.DataSource = items;
    this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;

private void Form1_Load(object sender, EventArgs e)
    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
    this.radGridView1.Columns["Date"].ExcelExportFormatString = "M/d/yyyy h:mm tt";
    this.radGridView1.Columns["Date"].ExcelExportType = DisplayFormatType.Custom;

    GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1);
    spreadExporter.ExportVisualSettings = true;
    SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
    string fileName = @"..\..\exportedFile" + DateTime.Now.ToLongTimeString().Replace(":", "_") + ".xlsx";
    spreadExporter.RunExport(fileName, exportRenderer);

Posted on: 22 Feb 2017 09:00
Thanks for getting back to us Adam. Would you mind posting this issue on the AJAX portal so you can get appropriate help: 
Adam Nelson
Posted on: 20 Feb 2017 18:51
AM/PM doesnt work either though, it gets replaced with A(Month value)/P(Month value)

Sorry, I didnt notice this was a WinForms related post so I havent tested it under this scenario but I can say that AM/PM does not work with exporting from the grid in the UI Ajax library
Ivan Petrov
Posted on: 19 Jan 2017 13:08
The "tt" part of the format string is actually not a valid date time format in MS Excel. To get the am/pm part of the date time value one should replace "tt" with "AM/PM". In the following article, you can find more details on formatting in MS Excel ( section Hours, minutes, and seconds).