dataRange property
Gets or sets the dataRange, which acts as a list type.
final Workbook workbook = Workbook(1);
//Accessing the first cell in excel-sheet and applying the dataRange property
final DataValidation dataRangeValidation =
sheet.getRangeByName('A1').dataValidation;
//Accessing the D1 cell and providing a text
sheet.getRangeByName('D1').text = 'ListItem1';
//Accesing the D2 cell and providing a text
sheet.getRangeByName('D2').text = 'ListItem2';
// Accessing a group of cell to be added to the list
dataRangeValidation.dataRange = sheet.getRangeByName('D1:D2');
//Save and dispose Workbook
final List<int> bytes = workbook.saveAsStream();
saveAsExcel(bytes, 'ExcelDataRangeValidation.xlsx');
workbook.dispose();
Implementation
late Range dataRange;