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

Radgrid Export to Excel Date format

1 Answer 569 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RAKESH
Top achievements
Rank 1
RAKESH asked on 15 Apr 2013, 01:20 PM
Hi,

When I tried to export data to excel, I'm unable to get date format. My date format is based upon my session settings. Date is displayed in grid as 10.01.2013 12.25.44. I want the same should be exported in excel. I'm using below code
protected void RadGrid1_ExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e)
        {
            StyleElement dateStyle = new StyleElement("Date");
            dateStyle.NumberFormat.FormatType = NumberFormatType.Fixed;
            dateStyle.NumberFormat.Attributes["ss:Format"] = "d";
            e.Styles.Add(dateStyle); 
        }
}

Thanks,
Kumar

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Apr 2013, 04:10 AM
Hi,

Try the following code.
C#:
protected void RadGrid1_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e)
{
    if ((e.FormattedColumn.UniqueName) == "Uniquename")
    {
        e.Cell.Style["mso-number-format"] = @"dd.MM.yyyy hh:mm:ss";
   }
}

Thanks,
Shinu
Tags
Grid
Asked by
RAKESH
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or