autoFit method
void
autoFit()
Changes the width of the columns and height of the rows in the Range to achieve the best fit.
Workbook workbook = new Workbook();
Worksheet sheet = workbook.worksheets[0];
//Auto-fit columns
Range range = sheet.getRangeByName('A1:D4');
range.autofit();
List<int> bytes = workbook.saveAsStream();
File('AutoFit.xlsx').writeAsBytes(bytes);
workbook.dispose();
Implementation
void autoFit() {
autoFitColumns();
autoFitRows();
}