Syncfusion.XlsIO.Base
Example 


CompareOperator Property

Gets or sets the comparison operation to perform. CompareOperator for Data Validation works with ExcelDataValidationComparisonOperator enumeration and two formula values.
Syntax
'Declaration
 
Property CompareOperator As ExcelDataValidationComparisonOperator
'Usage
 
Dim instance As IDataValidation
Dim value As ExcelDataValidationComparisonOperator
 
instance.CompareOperator = value
 
value = instance.CompareOperator
ExcelDataValidationComparisonOperator CompareOperator {get; set;}
Remarks
Comparison operator between Two formula values. To know more about CompareOperator property refer this link.
Example
The following code illustrates the use of CompareOperator property.
using Syncfusion.XlsIO;
using System.Drawing;
             
class Example
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
           //Create a worksheet.        
           IApplication application = excelEngine.Excel;
           application.DefaultVersion = ExcelVersion.Excel2013;
           IWorkbook workbook = application.Workbooks.Create(1);
           IWorksheet worksheet = workbook.Worksheets[0];
           worksheet.Range["A2"].CellStyle.Color = Color.LightGray;
           worksheet.Range["C2"].CellStyle.Color = Color.LightGray;
           worksheet.Range["E2"].CellStyle.Color = Color.LightGray;
           worksheet.Range["A1"].Text = "Text Vaidation";
           worksheet.Range["C1"].Text = "Time Vaidation";
           worksheet.Range["E1"].Text = "Number Vaidation";
           worksheet.Range["A1"].AutofitColumns();
           worksheet.Range["C1"].AutofitColumns();
           worksheet.Range["E1"].AutofitColumns();
            
           // Data validation for text length
           IDataValidation dataValidation = worksheet.Range["A2"].DataValidation;
           dataValidation.AllowType = ExcelDataType.TextLength;
           dataValidation.CompareOperator = ExcelDataValidationComparisonOperator.GreaterOrEqual; //Comparison operation for Data Validation
           dataValidation.FirstFormula = "5";
            
           // Date Validation for Time 
           IDataValidation dataValidation2 = worksheet.Range["C2"].DataValidation;
           dataValidation2.AllowType = ExcelDataType.Time;
           dataValidation2.CompareOperator = ExcelDataValidationComparisonOperator.Between; //Comparison operation for Data Validation
           dataValidation2.FirstFormula = "10:00";
           dataValidation2.SecondFormula = "12:00";
            
           //Data validation for number
           IDataValidation dataValidation3 = worksheet.Range["E2"].DataValidation;
           dataValidation3.AllowType = ExcelDataType.Integer;
           dataValidation3.CompareOperator = ExcelDataValidationComparisonOperator.NotBetween; //Comparison operation for Data Validation
           dataValidation3.FirstFormula = "0";
           dataValidation3.SecondFormula = "10";
            
           workbook.SaveAs("DataValidation.xlsx");
           workbook.Close();
           excelEngine.Dispose();
        }
     }
 }
AssemblyVersion

Syncfusion.XlsIO.Base: 17.2460.0.34

See Also