private XSSFDataValidation CreateValidation(XSSFSheet sheet) { //create the cell that will have the validation applied IRow row = sheet.CreateRow(0); row.CreateCell(0); IDataValidationHelper dataValidationHelper = sheet.GetDataValidationHelper(); IDataValidationConstraint constraint = dataValidationHelper.CreateCustomConstraint("true"); XSSFDataValidation validation = (XSSFDataValidation)dataValidationHelper.CreateValidation(constraint, new CellRangeAddressList(0, 0, 0, 0)); return(validation); }
public void TestDefaultAllowBlank() { XSSFWorkbook wb = new XSSFWorkbook(); try { XSSFSheet sheet = wb.CreateSheet() as XSSFSheet; XSSFDataValidation validation = CreateValidation(sheet); sheet.AddValidationData(validation); List <IDataValidation> dataValidations = sheet.GetDataValidations(); Assert.AreEqual(true, (dataValidations[0] as XSSFDataValidation).GetCTDataValidation().allowBlank); } finally { wb.Close(); } }