Completed
Last Updated: 19 Jun 2015 05:13 by Purvi
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 14 May 2015 15:44
Category: GridView
Type: Bug Report
1
FIX. RadGridView - SpreadExport does not take into consideration the GridViewDateTimeColumn.ExcelExportFormatString property
To reproduce:

this.radGridView1.DataSource = this.ordersBindingSource;
GridViewDateTimeColumn col = this.radGridView1.Columns["OrderDate"] as GridViewDateTimeColumn;
col.ExcelExportType = DisplayFormatType.GeneralDate;
col.ExcelExportFormatString = "dd-MMM-yy";

private void radButton1_Click(object sender, EventArgs e)
{
    SpreadExport spreadExporter = new SpreadExport(radGridView1);
    spreadExporter.RunExport(@"..\..\..\exportedFileQ12015.xlsx");

    Process.Start(@"..\..\..\exportedFileQ12015.xlsx");
}

Workaround:

private void radButton1_Click(object sender, EventArgs e)
{
    SpreadExport spreadExporter = new SpreadExport(radGridView1);
    spreadExporter.CellFormatting += spreadExporter_CellFormatting;
    spreadExporter.RunExport(@"..\..\..\exportedFileQ12015.xlsx");

    Process.Start(@"..\..\..\exportedFileQ12015.xlsx");
}

private void spreadExporter_CellFormatting(object sender, Telerik.WinControls.UI.Export.SpreadExport.CellFormattingEventArgs e)
{
    if (e.GridColumnIndex == 3 && e.GridCellInfo.Value is DateTime)
    {
        CellValueFormat cvf = new CellValueFormat("dd-MMM-yy");
        e.CellSelection.SetFormat(cvf);
    }
}
1 comment
Purvi
Posted on: 14 May 2015 18:57
Thanks for the Workaround, it helps!