I am reading an Excel file and displaying in DataGrid. I need to display the column cell name along with the cell values. For ex., if I have any value in column A, the data table's header should display as A, B, C, …, AA, BB, … But here I am seeing F1, F2, …
This is the image i'm getting.
I want the format as below.
string conn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName +
";Extended Properties='Excel 12.0;HDR=NO;IMEX=1;';";
using (OleDbConnection con = new OleDbConnection(conn))
{
string selectQuery = "SELECT * FROM [Sheet2$G1:L20]";
OleDbDataAdapter oleAdpt = new OleDbDataAdapter(selectQuery, con);
oleAdpt.Fill(dtexcel);
}
Any help would be really appreciated.