Problem exporting filtered rows only to Excel from RadGridView...

1 Answer 30 Views
GridView
Dan
Top achievements
Rank 1
Dan asked on 28 Jul 2022, 01:25 PM

I have a standard RadGridView that I've created functionality to export to Excel.  When I filter the rows of the RadGridView and then execute my export button, the spreadsheet still contains all of the rows.  How can I export filtered rows only ?

I've already tried ExcelML and that doesn't seem to export to .XLSX  format.  It does handle the filtering automatically.

 

Here is my code:

 

private void radButton_Export_Click_1(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1);
            SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
            RadOpenFolderDialog FolderDL = new RadOpenFolderDialog();
            
            FolderDL.InitialDirectory = @"\\mansply.local\shares\sales$\";
            FolderDL.ExpandToCurrentDirectory = false;
            DialogResult FolderDLR = FolderDL.ShowDialog();
            if (FolderDLR == DialogResult.OK)
            {
                string foldername = FolderDL.FileName;

                spreadExporter.RunExport(foldername + @"\ExportTest" + "-" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx", exportRenderer);      
            }
            Cursor = Cursors.Default;
        }

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Jul 2022, 09:27 AM

Hi, Dan,

The GridViewSpreadExport is a good approach for exporting RadGridView as it utilizes the RadSpreadProcessing library. 

I have prepared a sample project and tested exporting a filtered RadGridView. It seems to behave as expected with the latest version of the Telerik Ui for WinForms suite:

I have attached my sample project for your reference. Please give it a try and see how it works on your end.

Let me know what is the observed result.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Dan
Top achievements
Rank 1
commented on 29 Jul 2022, 12:54 PM

Thanks for the example project Dess.  I was able to get my project to work based on what I found in your example
Tags
GridView
Asked by
Dan
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or