Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
For Ex :

this is my excel having 100 lines . in that i want to add dropdown in "C" column for all 100 rows.

A   B    C  
1  aaa  DDL  
.  bbb  DDL
.  ccc	DDL	
.
.
.
1000


I've tried the below code .But it is taking time for due to 1000 record

C#
int iRowCount = Table1.Tables[0].Rows.Count;

        string[] ddl_item = { "Answers", "Autos", "Finance", "Games", "Groups" };

        for (int j = 2; j < iRowCount; j++)
        {
            xlsRange = xlWorkSheet.get_Range("A" + j, "A" + j);
            Excel.DropDowns xlDropDowns;
            Excel.DropDown xlDropDown;
            xlDropDowns = ((Excel.DropDowns)(xlWorkSheet.DropDowns(oMissing)));
            xlDropDown = xlDropDowns.Add((double)xlsRange.Left, (double)xlsRange.Top, (double)xlsRange.Width, (double)xlsRange.Height, true);

            for (int i = 0; i < ddl_item.Length; i++)
            {
                xlDropDown.AddItem(ddl_item[i], i + 1);
            }
        }


Any suggestions guys
Posted
Updated 6-Oct-15 23:25pm
v2

Hi Rajah,

Please refer below URL it reduce your item binding time.....

http://stackoverflow.com/questions/25659888/add-dropdown-list-in-the-excel-sheet-using-c-sharp[^]

Thanks,
Vaibhav
 
Share this answer
 
Comments
rajah rajah 7-Oct-15 6:21am    
Hi vaibav,
Thanks for your reply . i've tried that one also . thing is that i want to have ddl with data in excel with both data and value . like Name and id.consider,Once i select name Raja, i wanna save raja's id in my DB while uploading the same sheet.

This link we can have only list of strings .

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