Enum ValidationType

ValidationType enumeration

Represents data validation type.

public enum ValidationType

Values

NameValueDescription
AnyValue0Any value validation type.
WholeNumber1Whole number validation type.
Decimal2Decimal validation type.
List3List validation type.
Date4Date validation type.
Time5Time validation type.
TextLength6Text length validation type.
Custom7Custom validation type.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;

    public class ValidationTypeDemo
    {
        public static void ValidationTypeExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Add a validation to the worksheet
            ValidationCollection validations = worksheet.Validations;
            CellArea area = CellArea.CreateCellArea(0, 0, 1, 1);
            Validation validation = validations[validations.Add(area)];

            // Set validation type to WholeNumber
            validation.Type = ValidationType.WholeNumber;
            validation.Operator = OperatorType.Between;
            validation.Formula1 = "3";
            validation.Formula2 = "1234";

            // Set additional properties for the validation
            validation.InputMessage = "Please enter a whole number between 3 and 1234.";
            validation.InputTitle = "Whole Number Validation";
            validation.ErrorMessage = "The value must be a whole number between 3 and 1234.";
            validation.ErrorTitle = "Invalid Input";
            validation.ShowInput = true;
            validation.ShowError = true;

            // Save the workbook
            workbook.Save("ValidationTypeExample.xlsx");

            return;
        }
    }
}

See Also