Greyson Kirk

Greyson Kirk

  • NA
  • 1
  • 576

certain columns from dataGridView to certain columns excel

Aug 11 2016 3:10 PM
I have 3 columns (out of 10) in my dataGridView that I need to export to columns a,c, and i, in excel. 
 
 
for (int i = 1; i < dataGridView1.Columns.Count + 1; i++)
   { objexcelapp.Cells[1, i] = dataGridView1.Columns.Count - 1; i++ ;
}
for (int i = 0; i < dataGridView1.Rows.Count; i++)
   { for (int j = 0; j < dataGridView1.Columns.Count; j++)
{
      if (dataGridView1.Rows[i].Cells[j].Value != null)
{
         objexcelapp.Cells[i + 11, j + 1] = dataGridView1.Rows[i].Cells[j].Value.ToString();
}
}
}
 
 
right now i have everything exporting. Also, I am fairly new to c#.  
 
is this even possible?  

Answers (1)