autoFitColumns method

void autoFitColumns()

Changes the width of the columns 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.autofitColumns();

 List<int> bytes = workbook.saveAsStream();
 File('AutoFitColumns.xlsx').writeAsBytes(bytes);
 workbook.dispose();

Implementation

void autoFitColumns() {
  autoFitToColumn(column, lastColumn);
}