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

Export Selected Records from Radgrid to XSLX

1 Answer 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
NovoGuy
Top achievements
Rank 1
NovoGuy asked on 07 Oct 2016, 07:28 AM

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,

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 11 Oct 2016, 02:43 PM
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.
Tags
Grid
Asked by
NovoGuy
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or