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

RadGridView ExportToXlsx

1 Answer 251 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kristaps
Top achievements
Rank 1
Kristaps asked on 11 Aug 2017, 09:14 AM

Hi, 

I have problem of setting specific format for exporting data to excel. 

I wanted to use culture.NumberFormat.NumberGroupSeparator to set up no seperator and export it to excel.

But when setting modified culture to ExportToXlsx as a parameter, it doesnt affect anything.

I am doing something wrong?

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 16 Aug 2017, 07:44 AM
Hello Kristaps,

Could you please specify whether you've defined a DataFormatString for the column as this way the cell value will be exported in the same format as the value in the GridViewCell?

In such a scenario, you can handle the ElementExportingToDocument event and parse the exported value as per your requirements. Here's an example:

this.radGridView.ElementExportingToDocument += (s, e) =>
{
    if (e.Element == ExportElement.Cell)
    {
        var cellExportingArgs = e as GridViewCellExportingEventArgs;
        if ((cellExportingArgs.Column as GridViewDataColumn).DataType == typeof(int))
        {
            e.Value = int.Parse(e.Value.ToString().Replace(",", ""));
        }
    }
};

Please let me know if you find this applicable.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Kristaps
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or