Excel.Application excel = new Excel.Application();
excel.Visible = true;
object Missing = Type.Missing;
Workbook workbook = excel.Workbooks.Add(Missing);
Worksheet sheet1 = (Worksheet)workbook.Sheets[1];
int StartCol = 1;
int StartRow = 1;
for (int j = 0; j < dataGridView1.Columns.Count; j++)
{
Range myRange = (Range)sheet1.Cells[StartRow, StartCol + j];
myRange.Value2 = dataGridView1.Columns[j].HeaderText;
}
StartRow++;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
for (int j = 0; j < dataGridView1.Columns.Count; j++)
{
Range myRange = (Range)sheet1.Cells[StartRow + i, StartCol + j];
myRange.Value2 = dataGridView1[j, i].Value == null ? "" : dataGridView1[j, i].Value;
myRange.Select();
}
}
uyarlayamassanız özelden dönüş sağlayın yardım ederim