Articles in this section
Category / Section

How to export the grid with row headers and column headers in WinForms GridGroupingControl?

1 min read

The row and column headers of the WinForms GridGroupingControl can be exported to excel by using ConverterOptions property. GroupingGridToExcel() helps to trigger the converting of data from grid to excel.


private void button1_Click(object sender, EventArgs e)
   SaveFileDialog saveFileDialog = new SaveFileDialog();
   saveFileDialog.Filter = "Files(*.Xls)|*.Xls|Files(*.Xlsx)|*Xlsx";
   saveFileDialog.AddExtension = true;
   saveFileDialog.DefaultExt = ".Xls";
   saveFileDialog.FileName = "Book1";
   if (saveFileDialog.ShowDialog() == DialogResult.OK && saveFileDialog.CheckPathExists)
       excelConverter.GroupingGridToExcel(this.gridGroupingControl1, saveFileDialog.FileName, ConverterOptions.ColumnHeaders);
       if (MessageBox.Show("Do you wish to open the xls file now?", "Export to Excel", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
           System.Diagnostics.Process proc = new System.Diagnostics.Process();
           proc.StartInfo.FileName = saveFileDialog.FileName;


Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
   Dim saveFileDialog As New SaveFileDialog()
   saveFileDialog.Filter = "Files(*.Xls)|*.Xls|Files(*.Xlsx)|*Xlsx"
   saveFileDialog.AddExtension = True
   saveFileDialog.DefaultExt = ".Xls"
   saveFileDialog.FileName = "Book1"
   If saveFileDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK AndAlso saveFileDialog.CheckPathExists Then
      excelConverter.GroupingGridToExcel(Me.gridGroupingControl1, saveFileDialog.FileName, ConverterOptions.ColumnHeaders)
      If MessageBox.Show("Do you wish to open the xls file now?", "Export to Excel", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = System.Windows.Forms.DialogResult.Yes Then
         Dim proc As New System.Diagnostics.Process()
         proc.StartInfo.FileName = saveFileDialog.FileName
      End If
   End If
End Sub

Show the exporting dialog box

Show the data in excel


C#: Export to excel

VB: Export to excel

Reference link:

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment