Click here to Skip to main content
15,913,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello there,

Is it possible to set row 2 in excel file as header in c#? I've been googling a lot but I can't find my answer and not sure where to start. Your advice or sample code will be much appreciated.

Thanks in advance
Posted

1 solution

Hi, use below link for this:

Export to Excel from GridView in C#[^]

Above link shows that, how to export data to Excel and how to set cell by cell value, color and other properties.

Don't forget to mark if it is your solution. :-)
 
Share this answer
 
Comments
Member 8642100 21-Feb-12 11:17am    
Good article however i don't want to export data to gridview. I need to identify header at row 2 then copy the selected column into new excel file...
Sarvesh Kumar Gupta 21-Feb-12 11:50am    
I wrote below code

for (int i = 0; i < gridView.Columns.Count; i++) //GridView is id of gridview
{
dset.Tables[0].Columns.Add(gridView.Columns[i].HeaderText);
}
in this code place dset.Tables[1].
You get your 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