setColumnWidthInPixels method

void setColumnWidthInPixels(
  1. int iColumnIndex,
  2. int columnWidth
)

Sets column width in pixels for the specified row.

//Create a new Excel Document.
final Workbook workbook = Workbook();
// Accessing sheet via index.
final Worksheet sheet = workbook.worksheets[0];
// set columnWidth in pixels.
sheet.setColumnWidthInPixels(2, 20);
final List<int> bytes = workbook.saveAsStream();
File('ColumnWidth.xlsx').writeAsBytes(bytes);
workbook.dispose();

Implementation

void setColumnWidthInPixels(int iColumnIndex, int columnWidth) {
  final double dColumnWidth = _pixelsToColumnWidth(columnWidth);
  _setColumnWidth(iColumnIndex, dColumnWidth);
}