Export Selected Records from Radgrid to XSLX

2 posts, 0 answers
  1. NovoGuy
    NovoGuy avatar
    2 posts
    Member since:
    Mar 2011

    Posted 07 Oct Link to this post

    Hi Telerik,

    We are facing an issue of Exporting to XSLS from RadGrid. We recently change our export functionality to XSXL. Currently, we are using

    radgrid.ExportSettings.Excel.Format = GridExcelExportFormat.Xlsx;
    to export to XSLX for selected records.

    Ihave a functionality to export selected records. When I select some of records from Grid and export them we are getting all the records are exported to xslx file NOT only selected.
    The weird thing I faced is that when I change GridExcelExportFormat.Xlsx from GridExcelExportFormat.HTML, it works fine. (Only Selected Records are being exported)

    I am using following code to export selected records.

    if (radgrid.SelectedItems.Count != 0)
    {
      foreach (GridDataItem item in radEntityRecords.MasterTableView.Items)
       item.Visible = item.Selected;
    }
    radgrid.ExportSettings.OpenInNewWindow = true;
    radgrid.ExportSettings.ExportOnlyData = true;
    radgrid.MasterTableView.IsFilterItemExpanded = false;
    radgrid.ExportSettings.UseItemStyles = true;
    radgrid.MasterTableView.GroupByExpressions.Clear();
    radgrid.ExportSettings.Excel.Format = GridExcelExportFormat.Xlsx;
    radgrid.MasterTableView.ExportToExcel();


    Please suggest us,
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1800 posts

    Posted 11 Oct Link to this post

    Hi,

    In the provided code snippet you are changing the Visible property of items in another RadGrid (radEntityRecords) and not for the RadGrid initiating the export.

    Another possible cause for such problem might be if the RadGrid rebind before the export, which could be observed if the IgnorePaging export property is set to "true". If that is the case, you will have to disable the paging, store the selected items in some collection, rebind the grid and pre-select the item or change their visibility directly.

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik by Progress
    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