We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Create a combo box which has input range from other sheet

Hi

Can you help me in creating a excel with a combobox where the combox has an input range comming from second sheet : comboBox.InputRange = " ? ";

Regards

Tushar


This message was posted using Page2Forum from Aspose.Cells for .NET - Documentation

Hi,

Please see the following sample code for your requirement:

Sample code:

//Create a new Workbook.  
Workbook workbook = new Workbook();
//Add a new worksheet (2nd sheet).
Worksheet sheet = workbook.Worksheets.Add(“RangeSheet”); 
//Get the worksheet cells collection.
Cells cells = sheet.Cells;
//Input some values that denote the input range
//for the combo box.
cells[“A2”].PutValue(“Emp001”);
cells[“A3”].PutValue(“Emp002”);
cells[“A4”].PutValue(“Emp003”);
cells[“A5”].PutValue(“Emp004”);
cells[“A6”].PutValue(“Emp005”);
cells[“A7”].PutValue(“Emp006”);

//Get the first worksheet (default sheet)
Worksheet sheet1 = workbook.Worksheets[0];
//Input a value.
sheet1.Cells[“B3”].PutValue(“Employee:”);

//Add a new combo box.
Aspose.Cells.ComboBox comboBox = sheet1.Shapes.AddComboBox(2, 0, 2, 0, 22, 100);
//Set the linked cell;
comboBox.LinkedCell = “A1”;
//Set the input range.
comboBox.InputRange = “RangeSheet!A2:A7”;

//Set no. of list lines displayed in the combo
//box’s list portion.
comboBox.DropDownLines = 5;

//Set the combo box with 3-D shading.
comboBox.Shadow = true;

//AutoFit Columns
sheet1.AutoFitColumns();

//Saves the file.
workbook.Save(@“e:\test\test_combobox.xls”);

For further reference about using controls, see the document:
Adding Cell Controls in Worksheets

Thank you.