Hi
how can i show only date instead of datetime in excel sheet while exporting into excel.
i,e i have a column datatime column in grid while i am exporting data into a excel using exporttoexcel command , it is showing date with time but i just wanted to show only date(dd/MM/yyyy) format in excel sheet.
Note: i have set the format of exportsetting of excel to "ExcelML"
it's very urgent..
waiting for quick reply..
Thanks
Santosh
how can i show only date instead of datetime in excel sheet while exporting into excel.
i,e i have a column datatime column in grid while i am exporting data into a excel using exporttoexcel command , it is showing date with time but i just wanted to show only date(dd/MM/yyyy) format in excel sheet.
Note: i have set the format of exportsetting of excel to "ExcelML"
it's very urgent..
waiting for quick reply..
Thanks
Santosh
4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 20 Nov 2012, 09:15 AM
Hi Santosh,
Try the following code snippet to achieve your scenario.
C#:
Hope this helps.
Regards,
Princy.
Try the following code snippet to achieve your scenario.
C#:
protected
void
radgrid1_ExportCellFormatting(
object
sender, ExportCellFormattingEventArgs e)
{
if
(e.FormattedColumn.UniqueName ==
"UniqueName"
)
{
e.Cell.Style[
"mso-number-format"
] = @
"dd.MM.yyyy"
;
}
}
Hope this helps.
Regards,
Princy.
0
San
Top achievements
Rank 1
answered on 20 Nov 2012, 09:26 AM
Hi Princy,
i have tried this code but it's not working even
could you please give me some other code or is there any setting is there to resolve this problem.
Thanks
Santosh
i have tried this code but it's not working even
ExportCellFormatting
event is not firing. because of i guess my exportsetting format is excelML..could you please give me some other code or is there any setting is there to resolve this problem.
Thanks
Santosh
0
Princy
Top achievements
Rank 2
answered on 21 Nov 2012, 05:05 AM
Hi,
Try the following code to achieve your scenario.
C#:
Thanks,
Princy.
Try the following code to achieve your scenario.
C#:
protected
void
RadGrid1_ExcelMLExportStylesCreated(
object
sender, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLStyleCreatedArgs e)
{
StyleElement myStyle =
new
StyleElement(
"myCustomStyle"
);
myStyle.NumberFormat.FormatType = NumberFormatType.ShortDate;
e.Styles.Add(myStyle);
}
protected
void
RadGrid1_ExcelMLExportRowCreated(
object
sender, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs e)
{
e.Row.Cells.GetCellByName(
"Date"
).StyleValue =
"myCustomStyle"
;
}
Thanks,
Princy.
0
San
Top achievements
Rank 1
answered on 21 Nov 2012, 07:32 AM
hI princy,
Thanks for your reply..
i have already written the same code and it's working
but i want the same result without using these events or some other ways to get this result.
Thanks
Santosh
Thanks for your reply..
i have already written the same code and it's working
but i want the same result without using these events or some other ways to get this result.
Thanks
Santosh