dataValidation property
DataValidation
get
dataValidation
Gets the dataValidation for the Range.
//Creating one worksheet and accessing the first sheet
final Workbook workbook = Workbook(1);
final Worksheet sheet = workbook.worksheets[0];
//Accessing the first cell in worksheet and applying the Formula with Between property
final DataValidation formulaValidation =
sheet.getRangeByName('A1').dataValidation;
//sets the allowType
formulaValidation.allowType = ExcelDataType.formula;
//sets the compareOperator
formulaValidation.compareOperator =
ExcelDataValidationComparisonOperator.between;
//sets the listofValues
formulaValidation.listOfValues = <String>['List1', 'List2', 'List3'];
//Save and dispose Workbook
final List<int> bytes = workbook.saveAsStream();
saveAsExcel(bytes, 'ExcelFormulaValidationbetween.xlsx');
workbook.dispose();
Implementation
DataValidation get dataValidation {
if (isSingleRange) {
if (_dataValidationWrapper == null) {
final _DataValidationImpl? dv = _findDataValidation();
_dataValidationWrapper = _DataValidationWrapper(this, dv);
}
return _dataValidationWrapper!;
} else {
if (_dataValidationWrapper == null) {
final _DataValidationImpl? dv = _findDataValidation();
_dataValidationWrapper = _DataValidationWrapper(this, dv);
}
return _dataValidationWrapper!;
}
}