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

ExportToExcel with wrong/changing date format

1 Answer 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
lenuweit
Top achievements
Rank 1
lenuweit asked on 19 Apr 2017, 02:43 PM

I am using ExportToExcel and successfully generate an XLSX file from a RadGrid. Here is my event handler that is triggered from a custom button, not the built-in export button:

lvSearchResults.ExportSettings.FileName = "bla";
lvSearchResults.ExportSettings.IgnorePaging = true;
lvSearchResults.ExportSettings.OpenInNewWindow = true;
lvSearchResults.ExportSettings.Excel.Format = GridExcelExportFormat.Xlsx;
lvSearchResults.ExportSettings.Excel.FileExtension = "xlsx";      
lvSearchResults.MasterTableView.ExportToExcel();

 

My problem is that date columns are displayed correctly in the browser, but they are wrong and also changing in the resulting Excel file. I set the data format for my date columns as follows (as I generate all columns programmatically):

GridBoundColumn colEintritt = new GridBoundColumn();
lvSearchResultsMasterTableView.Columns.Add( colEintritt );
colEintritt.HeaderText = Glo.EwdFields.Eintritt;
colEintritt.DataField = "Eintrittsdatum";      
colEintritt.DataFormatString = "{0:dd.MM.yyyy}";

 

The Excel file has dates with a "wrong german" formatting, MM.dd.yyyy, and also MM/dd/yyyy. I cannot see why it formats one line like this and one like that. I'd be glad for a hint on how to get this correct.

Thanks and best regards,

Helge

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 21 Apr 2017, 10:58 AM
Hello Helge,

I've already replied to this query in your ticket with ID: 1104791. I suggest that we continue our conversation on the mentioned thread.

Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
lenuweit
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or