Skip to content

Data Validation Properties

OssianEPPlus edited this page Feb 15, 2023 · 8 revisions

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.

UID

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

Address

The cell 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 booleans. Namely

  • ShowErrorMessage
  • ShowPrompt
  • Allowblank
  • IsStale (Deprectated as of Epplus 6.2)

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 defines wheter the tooltip prompt when the cell is selected.

it represents this checkbox in Excel:

image

As of Epplus 6.2 both of these will be set to true by default.

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

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

image

IsStale indicates wheter this validation instance is stale, see: https://github.com/EPPlusSoftware/EPPlus/wiki/Data-validation-Exceptions NOTE: IsStale is Deprecated as of 6.2 as a Data Validation can no longer become stale. Instead all updates are done upon saving the ExcelPackage.

Input and Error Messages

PromptTitle, Prompt, ErrorTitle and Error are all string values for tooltip or error message in excel respectively.

PromptTitle and Prompt represent this field in Excel:

image

While ErrorTitle and Error represent this:

image

As

Ease of use property to cast dataValidation to its child-types easily.

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

EPPlus wiki

Versions

Worksheet & Ranges

Styling

Import/Export data

Formulas and filters

Charts & Drawing objects

Tables & Pivot Tables

VBA & Protection

Clone this wiki locally