Insert ComboBox into ExcelWorksheet through C#

I

im1dermike

I'm writing a C# program where I need to go through a loop and add a ComboBox
to an Excel spreadsheet cell. How do I do this?
 
I

im1dermike

I figured it out. It's actually a DropDown object I'm interested in...

protected static Excel.Application app;
protected static Excel.Range range;
protected static Excel.Workbook wb;
protected static Excel.Sheets sheets;
protected static Excel.Worksheet sheet;
protected static object oMissing = Missing.Value;

range = sheet.get_Range("N1", "N1");
Excel.DropDowns xlDropDowns;
Excel.DropDown xlDropDown;
xlDropDowns = ((Excel.DropDowns)(sheet.DropDowns(oMissing)));
xlDropDown = xlDropDowns.Add((double)range.Left,
(double)range.Top, (double)range.Width, (double)range.Height, true);

//Add items into drop down list
for (int i = 0; i < items.Length; i++)
{
xlDropDown.AddItem(items, i + 1);
}
 
I

im1dermike

I figured it out. It's actually a DropDown object I'm interested in...

protected static Excel.Application app;
protected static Excel.Range range;
protected static Excel.Workbook wb;
protected static Excel.Sheets sheets;
protected static Excel.Worksheet sheet;
protected static object oMissing = Missing.Value;

range = sheet.get_Range("N1", "N1");
Excel.DropDowns xlDropDowns;
Excel.DropDown xlDropDown;
xlDropDowns = ((Excel.DropDowns)(sheet.DropDowns(oMissing)));
xlDropDown = xlDropDowns.Add((double)range.Left,
(double)range.Top, (double)range.Width, (double)range.Height, true);

//Add items into drop down list
for (int i = 0; i < items.Length; i++)
{
xlDropDown.AddItem(items, i + 1);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top