# ExcelRangeDataValidationBuilder

Adds data validation rules to an ExcelRange.

Class 

`OfficeIMO.Excel`

**Namespace**

`OfficeIMO.Excel`

**Assembly**

`OfficeIMO.Excel`

**Source revision**

`273d35d5ba8a` with working tree changes

**Source**

[ExcelRangeDataValidationBuilder.cs:18](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRangeDataValidationBuilder.cs#L18)

**Modifiers**

sealed

Adds data validation rules to an [ExcelRange](/api/excel/officeimo-excel-excelrange/).

## Inheritance

- object
- ExcelRangeDataValidationBuilder

## Remarks

Existing rules are listed, edited and removed through the worksheet ([ExcelSheet.GetDataValidations](/api/excel/officeimo-excel-excelsheet/), [ExcelSheet.SetDataValidationMessages](/api/excel/officeimo-excel-excelsheet/), [ExcelSheet.UpdateDataValidationMessages](/api/excel/officeimo-excel-excelsheet/), [ExcelSheet.RemoveDataValidations](/api/excel/officeimo-excel-excelsheet/)).

## Usage

Explore 1 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 1

- Method [ExcelRange.Validation](/api/excel/officeimo-excel-excelrange/#method-validation)

Filter members 

Show inherited

## Methods

`public ExcelRange CustomFormula(string formula, bool allowBlank = true, string? errorTitle = null, string? errorMessage = null)` [#](#method-customformula-string-boolean-string-string)

[ExcelRangeDataValidationBuilder.cs:70](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRangeDataValidationBuilder.cs#L70)

Accepts input when a custom formula evaluates to true.

Parameters

**formula string required**

**allowBlank bool = true optional**

**errorTitle string? = null optional**

**errorMessage string? = null optional**

Returns

`ExcelRange`

`public ExcelRange Date(ExcelDataValidationOperator operator, DateTime formula1, DateTime? formula2 = null, bool allowBlank = true, string? errorTitle = null, string? errorMessage = null)` [#](#method-date-officeimo-excel-exceldatavalidationoperator-datetime-nullable-system-datetime-boolean-string-string)

[ExcelRangeDataValidationBuilder.cs:52](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRangeDataValidationBuilder.cs#L52)

Restricts input to dates; Between and NotBetween need formula2.

Parameters

**operator OfficeIMO.Excel.ExcelDataValidationOperator required**

**formula1 System.DateTime required**

**formula2 System.DateTime? = null optional**

**allowBlank bool = true optional**

**errorTitle string? = null optional**

**errorMessage string? = null optional**

Returns

`ExcelRange`

`public ExcelRange Decimal(ExcelDataValidationOperator operator, double formula1, double? formula2 = null, bool allowBlank = true, string? errorTitle = null, string? errorMessage = null)` [#](#method-decimal-officeimo-excel-exceldatavalidationoperator-double-nullable-system-double-boolean-string-string)

[ExcelRangeDataValidationBuilder.cs:46](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRangeDataValidationBuilder.cs#L46)

Restricts input to decimal numbers; Between and NotBetween need formula2.

Parameters

**operator OfficeIMO.Excel.ExcelDataValidationOperator required**

**formula1 double required**

**formula2 double? = null optional**

**allowBlank bool = true optional**

**errorTitle string? = null optional**

**errorMessage string? = null optional**

Returns

`ExcelRange`

List 2 overloads

`public ExcelRange List(params string[] items)` [#](#method-list-string)

[ExcelRangeDataValidationBuilder.cs:18](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRangeDataValidationBuilder.cs#L18)

Restricts input to a drop-down list of inline items.

Parameters

**items string[] required**

Returns

`ExcelRange`

`public ExcelRange List(IEnumerable<string> items, bool allowBlank = true)` [#](#method-list-collections-generic-ienumerable-system-string-boolean)

[ExcelRangeDataValidationBuilder.cs:22](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRangeDataValidationBuilder.cs#L22)

Restricts input to a drop-down list of inline items.

Parameters

**items System.Collections.Generic.IEnumerable<string> required**

**allowBlank bool = true optional**

Returns

`ExcelRange`

`public ExcelRange ListNamedRange(string namedRange, bool allowBlank = true)` [#](#method-listnamedrange-string-boolean)

[ExcelRangeDataValidationBuilder.cs:28](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRangeDataValidationBuilder.cs#L28)

Restricts input to a drop-down list read from a workbook or sheet-local named range.

Parameters

**namedRange string required**

**allowBlank bool = true optional**

Returns

`ExcelRange`

`public ExcelRange ListRange(string sourceA1Range, string? sourceSheetName = null, bool allowBlank = true)` [#](#method-listrange-string-string-boolean)

[ExcelRangeDataValidationBuilder.cs:34](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRangeDataValidationBuilder.cs#L34)

Restricts input to a drop-down list read from a worksheet range; the current sheet when no sheet is named.

Parameters

**sourceA1Range string required**

**sourceSheetName string? = null optional**

**allowBlank bool = true optional**

Returns

`ExcelRange`

`public ExcelRange TextLength(ExcelDataValidationOperator operator, int formula1, int? formula2 = null, bool allowBlank = true, string? errorTitle = null, string? errorMessage = null)` [#](#method-textlength-officeimo-excel-exceldatavalidationoperator-int32-nullable-system-int32-boolean-string-string)

[ExcelRangeDataValidationBuilder.cs:64](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRangeDataValidationBuilder.cs#L64)

Restricts the length of text input; Between and NotBetween need formula2.

Parameters

**operator OfficeIMO.Excel.ExcelDataValidationOperator required**

**formula1 int required**

**formula2 int? = null optional**

**allowBlank bool = true optional**

**errorTitle string? = null optional**

**errorMessage string? = null optional**

Returns

`ExcelRange`

`public ExcelRange Time(ExcelDataValidationOperator operator, TimeSpan formula1, TimeSpan? formula2 = null, bool allowBlank = true, string? errorTitle = null, string? errorMessage = null)` [#](#method-time-officeimo-excel-exceldatavalidationoperator-timespan-nullable-system-timespan-boolean-string-string)

[ExcelRangeDataValidationBuilder.cs:58](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRangeDataValidationBuilder.cs#L58)

Restricts input to times of day; Between and NotBetween need formula2.

Parameters

**operator OfficeIMO.Excel.ExcelDataValidationOperator required**

**formula1 System.TimeSpan required**

**formula2 System.TimeSpan? = null optional**

**allowBlank bool = true optional**

**errorTitle string? = null optional**

**errorMessage string? = null optional**

Returns

`ExcelRange`

`public ExcelRange WholeNumber(ExcelDataValidationOperator operator, int formula1, int? formula2 = null, bool allowBlank = true, string? errorTitle = null, string? errorMessage = null)` [#](#method-wholenumber-officeimo-excel-exceldatavalidationoperator-int32-nullable-system-int32-boolean-string-string)

[ExcelRangeDataValidationBuilder.cs:40](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Excel/ExcelRangeDataValidationBuilder.cs#L40)

Restricts input to whole numbers; Between and NotBetween need formula2.

Parameters

**operator OfficeIMO.Excel.ExcelDataValidationOperator required**

**formula1 int required**

**formula2 int? = null optional**

**allowBlank bool = true optional**

**errorTitle string? = null optional**

**errorMessage string? = null optional**

Returns

`ExcelRange`

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

<!-- PowerForge markdown artifact sha256:3BA6BD1952E60B7B0805DDEFCFE1C77FDC191C44785D0A94DB51B73B3C33D4BC -->
