Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 20-Apr-13 4:31am
v2

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 connectionstrings.com.
 
Share this answer
 
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900