如何在excel中添加下拉列表对于特定列的所有行。
问题描述:
对于Ex:
这是我的excel有100行。因为我想在所有100行的C栏中添加下拉列表。
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
我已经尝试过以下代码。但由于1000条记录需要时间
I've tried the below code .But it is taking time for due to 1000 record
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
答
Hi Rajah,
请参考以下网址,减少您的物品装订时间.....
http://stackoverflow.com/questions / 25659888 / add-dropdown-list-in-the-excel-sheet-using-c-sharp [ ^ ]
谢谢,
Vaibhav
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
https://support.office.com/en-in/article/Add-a-list-box-or-combo- box-to-a-worksheet-5ef0fee8-2a1e-43b2-bfea-67cf48fef130 [ ^ ]