I want to add drop down list in one of column of Excel sheet. How to add it using spreadsheetgear????
How to add a dropdownlist in excel using spreadsheetgear?
5.1k Views Asked by kumar At
2
There are 2 best solutions below
0

You can use cell Validation. It works similarly to how you do it in Excel.
private void CreateList(SpreadsheetGear.IRange cell, string list)
{
cell.Validation.Add(
SpreadsheetGear.ValidationType.List,
SpreadsheetGear.ValidationAlertStyle.Warning,
SpreadsheetGear.ValidationOperator.Default,
list, null);
}
In a windows forms program, you would call it something like this:
workbookView1.GetLock();
try
{
SpreadsheetGear.IRange cell =workbookView1.ActiveWorksheet.Cells["A1"];
CreateList(cell, "Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,Florida");
}
finally
{
workbookView1.ReleaseLock();
}
If you are trying to add a cell Data Validation dropdown list to a column, you can do this using the SpreadsheetGear.IValidation interface, available from the IRange.Validation property. I’ve provided some sample code below that demonstrates building two columns of data validation. Column B pulls its dropdown items from a range of cells on the same sheet; Column C pulls its dropdown items from a static list of values.
Note: I work at SpreadsheetGear and provide technical assistance for customers and evaluators of our product. Feel free to contact us at [email protected] if you have additional questions.