for (int i = 0; i < dgw_data.Rows.Count; i++) { DataGridViewRow row = dgw_data.Rows[i]; for (int j = 0; j < row.Cells.Count; j++) { ExcelApp.Cells[i + 1, j + 1] = row.Cells[j].ToString(); } }
ExcelApp.ActiveWorkbook.SaveCopyAs(saveFileDialog1.FileName.ToString()); ExcelApp.ActiveWorkbook.Saved = true; ExcelApp.Quit(); } }