0

first I want to say thank you all , You have a stuning Job here.
Secondly,
I Want to Import Data from Excel File to My DataGrideview columns.
I tried but data coms after My added columns.Please, Check my code bellow.

private void button8_Click_1(object sender, EventArgs e)
{
string content = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strExcelPathName.Text + "; Extended Properties=\"Excel 8.0;\";";
OleDbConnection con = new OleDbConnection(content);
OleDbDataAdapter oda = new OleDbDataAdapter("SELECT * FROM[" + txtSheet.Text + "$]", con);
DataTable dt = new DataTable();
oda.Fill(dt);
dataGridView1.DataSource = dt;
}
2
Contributors
10
Replies
46
Views
1 Month
Discussion Span
Last Post by ddanbe
Featured Replies
  • 1
    ddanbe 2,641   1 Month Ago

    I guess this is obvious from my previous post or did you not read the link? It offers a way to pick any range in excel and send it to C#. Read More

0

Dear ddanbe,
Means thats when columns(header) data should be come under the hears .

0

dear ddanbe
did'nt solve problem,
this artical is same as i made.
did u get my point ?
I Have Already DataGrideView with Headers, I want only import data from Excel file under thes headers.

0

ok I fetch Value of Excel File witout headers in DataGrideView but it Lefts Datagrideview Header and put these values next columns ........... what is problem?

0

Dear ddanbe,
I want excel data in my DataGrideView.Did u watch my image which i posted before?
Pleae, Tell me what is technique to skip cells before where excel data droped.......

1

I guess this is obvious from my previous post or did you not read the link? It offers a way to pick any range in excel and send it to C#.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.