Search code examples
epplusepplus-4

Create a column dropdown in EPPlus


I have everything else worked out but I want to put a drop down on a cell (range of cells) so that users are forced to select from the list.

I've tried this:

                var dd = worksheet.Cells[5, 3, row, 3].DataValidation.AddListDataValidation() as ExcelDataValidationList;
                dd.AllowBlank = true;
                //Add list here

But I can't find any method or property that allows me to link the list.

How is this done? I can't find any documentation on it.


Solution

  • The correct way is to use the Formula.Values.Add:

                    dd = worksheet.Cells[5, 4, row, 4].DataValidation.AddListDataValidation() as ExcelDataValidationList;
                    dd.AllowBlank = true;
                    dd.Formula.Values.Add("Yes");
                    dd.Formula.Values.Add("No");