2

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.

James Hancock
  • 3,348
  • 5
  • 34
  • 59
  • Possible duplicate of [Excel & EPPlus .NET library: Advanced DropDown list validation](https://stackoverflow.com/questions/28210584/excel-epplus-net-library-advanced-dropdown-list-validation) – Yahya Hussein Jan 19 '18 at 14:41
  • won't this answer work for you? – Yahya Hussein Jan 19 '18 at 14:43
  • It will, but the api directly allows you to pass an array directly instead of having to have additional sheets which is what I'm trying to avoid. – James Hancock Jan 19 '18 at 16:22

1 Answers1

2

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");
James Hancock
  • 3,348
  • 5
  • 34
  • 59