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

Export to Excel Datetime

1 Answer 209 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 05 Apr 2016, 03:57 PM

I'm running into an issue with format of a datetime column when exporting to excel.

What I am trying to do is export  datetime column to excel and format as the full datetime on excel, how the various approaches i have tried do not seem to work.

I can get the export to appear to show up as a datetime by:
column.ExcelFormatString = "M/d/yyyy h:mm tt"
column.ExcelExportType = DisplayFormatType.Text;

 

The problem with this is, that when i put I put a filter on the column in excel, it only sorts alphabetically not by date.

The closest I am able to get behavior wise is this:
column.ExcelFormatString = "M/d/yyyy h:mm"
column.ExcelExportType = DisplayFormatType.Custom;

 

This allows me to sort by date, but makes the time portion 24 hr format. If I try this with "M/d/yyyy h:mm tt" it ignores the AM/PM indicator and just writes "tt" at the end.

Ideally what I would like is a away to get the datetime to show up in 12 hour format in excel ("M/d/yyyy h:mm tt") while still being able to sort by Earliest/Latest instead of Alphabetically.

Any help would be appreciated, thanks.

 



1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Apr 2016, 08:35 AM
Hello Matt,

Thank you for writing.

Indeed, the AM/PM time part is not respected. I have logged it in our feedback portal. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item.

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to use one of the custom text formats or manipulate the cell's text in the GridViewSpreadExport.CellFormatting event.

I hope this information helps. Should you have further questions I would be glad to help.

 Regards,

Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Matt
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or