I wanted to know if there is a way to retain grouping, sorting, and filteringg set in a WinForms RadGrid when exporting to Excel.
I have a WinForms application that uses the RadGridview to allow users to sort and group items, however currently when they export the data to Excel the data only exports when they do not have any items grouped.
I wanted to know how I could allow them to use the RadGridview to group, sort, and filter the items then keep those settings when the data is exported to Excel. Are there some settings I need to enable in the Gridview itself or modifications that need to be made to the Export sub-routine to allow this.
This is the code that is run when a user clicks the export to Excel button:
Private Sub btnExportToExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExportToExcel.Click |
If SaveFileDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then |
If (Not SaveFileDialog.FileName.Equals(String.Empty)) Then |
Dim file As New FileInfo(SaveFileDialog.FileName) |
If file.Extension.Equals(".xls") Then |
Export(SaveFileDialog.FileName) |
Else |
MessageBox.Show("Invalid file type") |
End If |
Else |
MessageBox.Show("Please enter a file name.") |
End If |
Me.btnExportToExcel.Enabled = True |
End If |
End Sub |
Private Sub Export(ByVal filepath As String) |
Me.btnExportToExcel.Enabled = False |
Dim exporter As New ExportToExcelML() |
Dim exportThemeColors As Boolean = True |
exporter.RunExport(Me.grdData, filepath, ExportToExcelML.ExcelMaxRows._65536, exportThemeColors) |
Me.btnExportToExcel.Enabled = True |
MessageBox.Show("Exporting Finished.") |
End Sub |