Skip to content

Data Validation Properties

Mats Alm edited this page Nov 6, 2023 · 8 revisions

Summary

On this page we bring up a few aspects of adding DataValidations that might be good to know or might seem unexpected at first and explain the function of the base properties.

Screenshots in this article are from version 2301 build 16.0 of Excel in Office 365 and were taken in 2023.

Properties

UID

Each Validation created with Epplus has a unique ID number attached to it.

Address

The cell or range the DataValidation has been applied to.

ValidationType

An enum defining what type the current validation is.

ValidationType represents this field in Excel:

image

ErrorStyle

Enum to define type of error to show if input is invalid.

Represents this menu in Excel

image

Booleans

Each data validation contains a few boolean properties:

  • ShowErrorMessage
  • ShowPrompt
  • Allowblank
  • IsStale

ShowErrorMessage

Notably the data validation will not stop faulty inputs if ShowErrorMessage is false. It is false by default so in most cases you'll want to set it to true even if you don't specify a unique error message.

ShowErrorMessage represents this checkbox in Excel:

image

ShowPrompt

ShowPrompt defines wheter the tooltip prompt when the cell is selected.

it represents this checkbox in Excel:

image

AllowBlank

AllowBlank lets you not fill in formulas when true even if the validation will not work with empty fields. Can be used to avoid compilation errors when performing certain unit tests where only some properties of the validation is relevant for example.

It represents this checkbox in Excel:

image

IsStale

NB! This property is deprecated from EPPlus 6.2 (which has a new implementation of Data Validations).

IsStale indicates wheter this validation instance is Stale

HideDropDown

In addition ExcelDataValidationList contains a boolean for showing the dropdown menu or not called HideDropDown.

image

Input and Error Messages

PromptTitle, Prompt, ErrorTitle and Error are all string values for tooltips or error messages in Excel respectively.

PromptTitle and Prompt represent this field in Excel:

image

While ErrorTitle and Error represent this:

image

As

Data validations read from a workbook are always returned as ExcelDataValidation instances. Use the As property to cast a data validation to its specialized type.

Formula

Every data validation (Except the AnyDatavalidation type) has one or two Formula properties Each formula has either .Value, .ExcelFormula or both.

Value is a typed value which is different for each type of validation for ExcelDataValidationInteger its an int for ExcelDataValidationDateTime it's a DateTime and so on.

ExcelFormula however is always a string and is meant to represent choosing cell ranges (especially with the List data validation) or to simply input an excelFormula like ISNUMBER(A1) for a custom formula for example

Formula and Formula2 represent the following fields in Excel:

image

Operator

Enum that defines the basis of comparison for the validation between, greaterThan, LessThan etc.

Represented by this field in Excel:

image

See also

EPPlus wiki

Versions

Worksheet & Ranges

Styling

Import/Export data

Formulas and filters

Charts & Drawing objects

Tables & Pivot Tables

VBA & Protection

Clone this wiki locally