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

Issue on Export to Excel from RadGriDView

2 Answers 173 Views
GridView
This is a migrated thread and some comments may be shown as answers.
P
Top achievements
Rank 1
P asked on 28 Oct 2016, 07:28 AM

Hello  we are facing problem while exporting direct from RadGridView to Excel. After exporting data, three problems are there in excel sheet.

1. Phone numbers are getting chopped off [Like "8.70772E+11" instead of "870772001799"]

[Instead of In DataTable PHONENUMBER is in String type]

2. Phone numbers are displaying as Right Align [Instead data type is String]     

[Images given "Image .XLS file after exported .png"]

3. Group name is not showing in Excel sheet  [Only first group is not showing]

Please advice.

Screenshot are given & the used code given bellow.  

private void Button_export_Click(object sender, System.Windows.RoutedEventArgs e)
        {
 
            string extension = "xls";
            string selectedItem = "Excel";
 
            ExportFormat format = ExportFormat.Html;

            SaveFileDialog dialog = new SaveFileDialog();
            dialog.DefaultExt = extension;
            dialog.Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, selectedItem);
            dialog.FilterIndex = 1;
 
            if (dialog.ShowDialog() == true)
            {
                using (Stream stream = dialog.OpenFile())
                {
                    GridViewExportOptions options = new GridViewExportOptions();
                    options.Format = format;
                    options.ShowColumnHeaders = true;
                    
                    options.Encoding = Encoding.UTF8;
                    radGridViewSearch.Export(stream, options);
                }
            }

            MessageBox.Show("Successfully Exported");
 
        }

 

Thanks

2 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 01 Nov 2016, 11:20 AM
Hello,

I have tested the behavior and was not able to observe the undesired effects when using the ExportToXlsx extension method of RadGridView.  Please give it a try and update me how it works for you. I have added a sample project for your reference.

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
0
Mohsen
Top achievements
Rank 1
answered on 30 Nov 2019, 02:45 PM

Hi Dear Stefan

I have same problem also.

in multi header radgridview if I use same name for sub headers name when try to export to excel, it removes equal names and the whole sheet become a mess.

Tags
GridView
Asked by
P
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Mohsen
Top achievements
Rank 1
Share this question
or