Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello everyone. I am developing a excel plugin in which i have a window form which contains listbox and a button. I want to fetch excel column headers of activesheet like A,B,C,etc. in the listbox alonwith full column values on button click. I searched a lot on it but did not found anything.I am using visual studio 2010 (visual c#) I will be really thankful for any help.
Posted
Updated 27-Mar-14 1:51am
v3
Comments
Ankur Ramanuj 27-Mar-14 8:13am    
you want column header name which you provided in excel?

 
Share this answer
 
Comments
R@ju Gupta 27-Mar-14 11:09am    
thanks for reply but your answer is not my solution .
Kannan Subramaniam 28-Mar-14 1:56am    
Try OpenXML or some opensource Excel API's
i have solved it by myself.

C#
 Microsoft.Office.Interop.Excel.Worksheet activeSheet =
(Microsoft.Office.Interop.Excel.Worksheet)Globals.ThisAddIn.Application.ActiveSheet; 


if use from combobox then,

C#
Excel.Range rng = activeSheet.UsedRange.Columns["" + comboBox2.SelectedItem + "", System.Type.Missing];
            
rng.Select();

or

C#
Excel.Range rng = activeSheet.UsedRange.Columns["A", System.Type.Missing];
            
rng.Select();


it works fine for me.
 
Share this answer
 
v2

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