Hello I'm trying to translate an Excel file to my dataGridView and it's having column name issues because the way the Excel file is formatted, there are two setup cells for the rest of the document. However the Column names are actually on Row #2. How can I skip the first row in the file read so that the Columns in the dataGridView show the cell values from the second row?
Current code:
var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0; data source={0}; Extended Properties=Excel 8.0;", openFileDialog1.FileName);
string query = String.Format("select * from [{0}$]", "Sheet1");
var adapter = new OleDbDataAdapter(query, connectionString);
DataSet ds = new DataSet();
adapter.Fill(ds);
DataTable dt = ds.Tables[0];
techGrid.DataSource = dt;
See Question&Answers more detail:os