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

2 posts, 0 answers
  1. Vaishali
    Vaishali avatar
    2 posts
    Member since:
    Apr 2016

    Posted 04 May Link to this post

    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.
  2. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 09 May Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top