try
{
Microsoft.Office.Interop.Excel.Application ExcelApp = new Microsoft.Office.Interop.Excel.Application();
ExcelApp.Application.Workbooks.Add(Type.Missing);
int i;
int ii;
int j;
for (i = 1; i < dgvAssetResult.Columns.Count + 1; i++)
{
ExcelApp.Cells[1, i] = dgvAssetResult.Columns[i - 1].HeaderText;
}
for (ii = 0; ii < dgvAssetResult.Rows.Count; ii++)
{
for (j = 0; j < dgvAssetResult.Columns.Count; j++)
{
ExcelApp.Cells[ii + 2, j + 1] = dgvAssetResult.Rows[ii].Cells[j].Value.ToString();
}
}
string ls_FileName ="E:\Test.xls";
ExcelApp.ActiveWorkbook.SaveCopyAs(ls_FileName);
ExcelApp.ActiveWorkbook.Saved = true;
ExcelApp.Quit();
}
catch
{
}
Using this method on button click. Add the proper references