Нужно экспортировать таблицу из datagridview в excel. Язык c#. В NuGet скачал Microsoft.Office.Interop.Excel.
using Excel = Microsoft.Office.Interop.Excel;
private void button11_Click(object sender, EventArgs e)
{
Excel.Application exApp = new Excel.Application();
exApp.Visible = true;
exApp.Workbooks.Add();
Worksheet workSheet = (Worksheet)exApp.ActiveSheet;
workSheet.Cells[1, 1] = "ID";
workSheet.Cells[1, 2] = "Name";
int rowExcel = 2;
for (int i = 0; i < dataGridView2.Rows.Count; i++)
{
workSheet.Cells[rowExcel, "A"] = dataGridView2.Rows[i].Cells["ID"].Value;
workSheet.Cells[rowExcel, "B"] = dataGridView2.Rows[i].Cells["Name"].Value;
++rowExcel;
}
workSheet.SaveAs("MyFile.xls");
exApp.Quit();
}