Completed
Last Updated: 07 Jul 2020 08:23 by ADMIN
Release R3 2020 (LIB 2020.2.713)
Ira
Created on: 02 Jul 2020 11:51
Category: GridView
Type: Bug Report
0
RadGridView: when grid is grouped hidden SummaryRows are not exported in Excel
When the grid is grouped and there are hidden summary rows, the summary rows are not exported.
1 comment
ADMIN
Nadya | Tech Support Engineer
Posted on: 02 Jul 2020 12:30

Hello,

To workaround, create a collection of hidden summary rows that are not visible in the grid, but you would like to export in the excel file:

 Dim hiddenRows As List(Of GridViewRowInfo) = New List(Of GridViewRowInfo)()
 Private Sub radGridView1_ViewCellFormatting(sender As Object, e As UI.CellFormattingEventArgs) _
     Handles radGridView1.ViewCellFormatting

     '  hide summary row except when exporting
     If TypeOf e.CellElement Is GridSummaryCellElement Then
         e.Row.IsVisible = Me.Exporting
         If Not Me.hiddenRows.Contains(e.Row) Then
             Me.hiddenRows.Add(e.Row)
         End If
     End If

 End Sub

 Private Sub btnExport_Click(sender As Object, e As EventArgs) Handles RadAButton1.Click

     Me.Exporting = True
     For Each row As GridViewRowInfo In Me.hiddenRows
         row.IsVisible = Me.Exporting
     Next
     Me.radGridView1.TableElement.Update(GridUINotifyAction.StateChanged)


     Dim file As String = "C:\TEMP\ExportText.xlsx"

     '  delete file if it exists
     If System.IO.File.Exists(file) = True Then
         System.IO.File.Delete(file)
     End If

     Dim spreadExporter As GridViewSpreadExport = New GridViewSpreadExport(Me.radGridView1)
     Dim exportRenderer As New SpreadExportRenderer()

     spreadExporter.ExportVisualSettings = True
     spreadExporter.ExportGroupedColumns = True
     spreadExporter.HiddenRowOption = UI.Export.HiddenOption.ExportAlways
     spreadExporter.SummariesExportOption = UI.Export.SummariesOption.ExportAll
     spreadExporter.RunExport(file, exportRenderer)

     Process.Start(file)
     Me.Exporting = False
     For Each row As GridViewRowInfo In Me.hiddenRows
         row.IsVisible = Me.Exporting
     Next
     Me.radGridView1.TableElement.Update(GridUINotifyAction.StateChanged)
 End Sub

Regards,
Nadya
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.