Xceed Workbooks for .NET v2.0 Documentation
DataValidation Class
Members  Example 


Xceed.Workbooks.NET Assembly > Xceed.Workbooks.NET Namespace : DataValidation Class
Represents the data validation process used to validate the content of a Cell.
Syntax
'Declaration
 
Public Class DataValidation 
'Usage
 
Dim instance As DataValidation
public class DataValidation 
Remarks
The data validation process triggers warnings when the wrong type of data is entered in a Cell.
Example
using( var workbook = Workbook.Create( "AddDataValidation.xlsx" ) ) 
  { 
    // Gets the first Worksheet; a Workbook always contains at least 1 Worksheet. 
    var worksheet = workbook.Worksheets[ 0 ]; 

    // Creates a new DataValidation and assign it to Cells A1 to A3. 
    var dataValidation = new DataValidation( ValidationType.Decimal, DataComparisonType.LessThanOrEqual ) { Value = 10 }; 
    dataValidation.SetError( "My Error", "Value must under 10", DataValidationErrorStyle.Warning ); 
    worksheet.Cells[ "A1", "A3" ].DataValidation = dataValidation; 

    // Saves Workbook to disk; 
    workbook.Save(); 
  }
Inheritance Hierarchy

System.Object
   Xceed.Workbooks.NET.DataValidation

Requirements

Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

DataValidation Members
Xceed.Workbooks.NET Namespace