Click here to Skip to main content
13,047,131 members (59,776 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How do I tell a DataGridView NOT to create column headers from the
first row of a data table using an Excel datasource?
Posted 20-Apr-13 2:43am
Updated 20-Apr-13 4:31am
Mehdi Gholam339.4K
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Depending on how you're bringing the data into your DataGridView, you would probably specify it in your connection string using "HDR=NO".

If you're using a normal *.xlsx file, then your connection string would look something like the one below:

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;
Extended Properties="Excel 12.0 Xml;HDR=NO";"

Other variations of the above are shown at
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Thanks for your Reply traciray.

Actually i had specified that HDR=No in my connection string but still it was taking my 1st dataTables row as column header.

There was also one more parameter in my connection string IMEX which was set to 2. this when i changed to 1 it worked for me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 23 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100