how to add a drop down list in excel spreadsheet code example
Example 1: create dropdown in spreadsheet
1. Open a spreadsheet in Google Sheets.
2. Select the cell or cells where you want to create a drop-down list.
1. Click Data and then Data validation.
2. Next to "Criteria," choose an option:
3. List from a range: Choose the cells that will be included in the list.
4. List of items: Enter items, separated by commas and no spaces.
5. The cells will have a Down arrowDown Arrow. To remove the arrow, uncheck "Show dropdown list in cell."
6. If you enter data in a cell that doesn’t match an item on the list, you’ll see a warning. If you want people to only enter items from the list, choose "Reject input" next to "On invalid data."
7. Click Save. The cells will show a drop-down list. To change the color of a cell based on the option selected, use conditional formatting.
Example 2: excel sheet with drop down list
var options = new List{"Option1","Option2","Option3"};
var validOptions = $"\"{String.Join(",", options)}\"";
ws.Cell(1,1).DataValidation.List(validOptions, true);
//validOptions contains :
"Option1,Option2,Option3"
//Your own code should change to :
.List("\"one,two,three\"", true);