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

Issue with "Save as type" for excel(xls) exported using RadGrid export to excel.

1 Answer 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vaishali
Top achievements
Rank 1
Vaishali asked on 04 May 2016, 01:22 PM

I have a radgrid, whose data i am exporting to excel (xls) format using radGrid.MasterTableView.ExportToExcel(), export is working as expected, but when I open the exported xls file and click "Save as", the "Save as type:" is set to "Web Page(.htm.html)", it is expected to be "Excel Workbook(*.xlsx)". The export code is as below,

radGrid.ExportSettings.FileName = "Export";
radGrid.ExportSettings.HideStructureColumns = true;
radGrid.ExportSettings.OpenInNewWindow = true;
radGrid.ExportSettings.ExportOnlyData = true;
radGrid.MasterTableView.GroupsDefaultExpanded = true;
radGrid.MasterTableView.Caption = string.Empty;
radGrid.MasterTableView.ExportToExcel();

Please suggest.Thank you.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 09 May 2016, 11:09 AM
Hello Vaishali,

Please make sure that you are not using DataBind() to bind the grid. Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:

Declarative DataSource (DataSourceID property)
Programmatic Data Binding (NeedDataSource event, + DetailTableDataBind for hierarchy). You should set the DataSource property only within these event handlers.

Do you face this issue with the live sample provided here?
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/exporting/excel-export/defaultcs.aspx

Regards,
Eyup
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Vaishali
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or