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