Excel Library and EPPlus.NET: Advanced DropDown List Validation

In Epplus, when we create a DropDown list for some cells in the excel file, the user enters a value that is not part of the list, the cell displays a message: the value must correspond to one of the listed elements.

Instead of this message, is it possible to prevent the user from putting a value that is not part of the drop-down list?

Thanks in advance,

+5
source share
1 answer

I did this with the following code:

//ExcelWorksheet ws var validation = ws.DataValidations.AddListValidation(cell.Address); validation.ShowErrorMessage = true; validation.ErrorStyle = ExcelDataValidationWarningStyle.stop; validation.ErrorTitle = "Error"; validation.Error = "Error Text"; // sheet with a name : DropDownLists // from DropDownLists sheet, get values from cells: !$A$1:$A$10 var formula = "=DropDownLists!$A$1:$A$10" //Applying Formula to the range validation.Formula.ExcelFormula = formula; 
+8
source

Source: https://habr.com/ru/post/1212175/


All Articles