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

Free Support Forum - aspose.com

Creating Drop Downs in Excel

Hi Team,

I want to generate an excel sheet which will have 2 drop downs but the values for both drop downs would be dynamic.

also there will be other columns in the excel which too are dynamic, there count will vary.

Please help me how to do this in aspose



There are different ways to create combo box control. You may consider following sample code where column F is targeted as combo box source data. You may append/delete data in F column and combo box shall pick data dynamically from this column. For this purpose Range is created based upon maximum rows in the column F. Using this example you may create your desired output file.

If this sample does not fulfill your requirement, please prepare your required output workbook using Excel and share with us along with the sample code (if any). We will try to provide you assistance to create similar output using Aspose.Cells.

// Create a new Workbook.
Workbook workbook = new Workbook();

// Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];

// Get the worksheet cells collection.
Cells cells = sheet.Cells;

// Input a value.

// Set it bold.
cells["G3"].GetStyle().Font.IsBold = true;

// Input some values that denote the input range
// For the combo box.

// Add a new combo box.
Aspose.Cells.Drawing.ComboBox comboBox = sheet.Shapes.AddComboBox(2, 0, 7, 0, 22, 100);
// ExEnd:1
// Set the linked cell;
comboBox.LinkedCell = "F1";
Aspose.Cells.Range range = cells.CreateRange("F2", CellsHelper.CellIndexToName(cells.GetLastDataRow(5), 5));
range.Name = "Students";
// Set the input range.
//comboBox.InputRange = "F2:F7";
comboBox.InputRange = "=Students";

// 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

// Saves the file.