Document Solutions for Excel, Java Edition | Document Solutions
Features / Data Validations / Delete Validation
In This Topic
    Delete Validation
    In This Topic

    You can delete an existing validation rule applied to a cells or range of cells in a worksheet using the delete method of the IValidation interface.

    You can use the following example code to delete an existing validation rule which was previously applied to a cell or a range of cells in a worksheet.

    Java
    Copy Code
            
    Calendar time1 = new GregorianCalendar(1899, 11, 30, 13, 30, 0);
    Calendar time2 = new GregorianCalendar(1899, 11, 30, 18, 30, 0);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh:mm:ss");
            
    // Add Validation
    worksheet.getRange("A1:A2").getValidation().add(ValidationType.Date, ValidationAlertStyle.Stop,
            ValidationOperator.Between, simpleDateFormat.format(time1.getTime()),
            simpleDateFormat.format(time2.getTime()));
    // Delete validation.
    worksheet.getRange("A1:A2").getValidation().delete();