We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Using Grid View for Excel

I'm trying to find the correct syntax for searching the columns in a Syncfusion Grid. I'm exporting data to Excel with a button click from data in the grid viewer. I'm basically viewing a bunch of data in the Syncfusion equivalent of a data grid viewer for the standard C# VS. Below is the code. It errors on the Columns and Rows section of the code. Perhaps there is an assembly reference I am not seeing but I've added almost all of them and it still doesn't work.

for (int i =1; i < CK_QA_DataGridView.Columns.Count + 1, i++)
     ExcelApp.Cells[1, i] = CK_QA_DataGridView.Columns[i - 1].HeaderText;

for (int i = 0; i < CK_QA_DataGridview.Rows.Count; i++)
    for (int j = 0; j < CK_QA_DataGridview.Columns.Count; j++)
              ExcelApp.Cells[i + 2, j +1] = CK_QA_DataGridView.Rows[i].Cells[j].Value.ToString();

Any help would be appreciated.

1 Reply

SA Solai A L Syncfusion Team March 4, 2015 06:38 AM UTC

Hi Kevin,

Thank you for your interest in Syncfusion Products.

In order to achieve your requirement please make use of QueryImportExportCellInfo event of GridExcelConvertercontrol class. Please refer the below code snippet and sample for reference. In this sample , Export button click has been hooked with the event QueryImportExportCellInfo.


private void Export_Click(object sender, System.EventArgs e)


                     Syncfusion.GridExcelConverter.GridExcelConverterControl gecc = new Syncfusion.GridExcelConverter.GridExcelConverterControl();


                     SaveFileDialog saveFileDialog = new SaveFileDialog();

                     saveFileDialog.Filter = "Files(*.xls)|*.xls";

                     saveFileDialog.DefaultExt = ".xls";

            gecc.QueryImportExportCellInfo += gecc_QueryImportExportCellInfo;

                     if(saveFileDialog.ShowDialog() == DialogResult.OK)


                           gecc.GridToExcel(this.gridDataBoundGrid1.Model, saveFileDialog.FileName,


                           if(MessageBox.Show("Do you wish to open the xls file now?", "Export to Excel", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)


                                  Process proc = new Process();

                                  proc.StartInfo.FileName = saveFileDialog.FileName;







        void gecc_QueryImportExportCellInfo(object sender, GridImportExportCellInfoEventArgs e)


            if (e.ColIndex > 0 && e.RowIndex > 0 && (this.gridDataBoundGrid1.Binder.InternalColumns[e.ColIndex-1].HeaderText == "CustomerID"))


                //now the column name with CustomerID has been identified.








Please let us know if you have any other concerns.


Thanks & Regards,



Live Chat Icon For mobile
Up arrow icon