Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 3:43am
Edited 20-Apr-13 5:31am
Mehdi Gholam253.6K
v2
Rate this: bad
good
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 connectionstrings.com.
  Permalink  
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 334
1 Kornfeld Eliyahu Peter 325
2 Maciej Los 239
3 OriginalGriff 188
4 King Fisher 185
0 OriginalGriff 6,303
1 DamithSL 4,764
2 Maciej Los 4,306
3 Kornfeld Eliyahu Peter 3,914
4 Sergey Alexandrovich Kryukov 3,538


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 23 Apr 2013
Copyright © CodeProject, 1999-2014
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