You are here

protected function Xls::setColumnsAutoSize in Excel Serialization 8

Set width of all columns with data in them in sheet to AutoSize.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $sheet: The worksheet to set the column width to AutoSize for.

1 call to Xls::setColumnsAutoSize()
Xls::encode in src/Encoder/Xls.php
Encodes data into the given format.

File

src/Encoder/Xls.php, line 343

Class

Xls
Adds XLS encoder support for the Serialization API.

Namespace

Drupal\xls_serialization\Encoder

Code

protected function setColumnsAutoSize(Worksheet $sheet) {
  foreach ($sheet
    ->getColumnIterator() as $column) {
    $column_index = $column
      ->getColumnIndex();
    $sheet
      ->getColumnDimension($column_index)
      ->setAutoSize(TRUE);
  }
}