2

I am using PHPSpreadsheet and I'm doing the following to autosize the relevant columns:

foreach (range('A', 'K') as $col) {
    $productsSheet->getColumnDimension($col)->setAutoSize(true);
}

The issue is, however, that extra padding is added.

The following is when I use autosize with using the setAutoSize function: PHPSpreadsheet

And here it is after doing the autosize in Excel:

Excel

It becomes even more prominent for wider cells thus making the export far wider than it needs to be.

Is there anything that can be done about this, manually setting the width of each column is not acceptable for us as the content is highly variable.

Matthew Knill
  • 252
  • 2
  • 7

0 Answers0