aVadim483 / fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setColWidthAuto resizer not working 100% effectively

elidon555 opened this issue · comments

SetColWidthAuto doesn't work correctly when you also use setAutofilter

$worksheet->writeHeader($headers);
$worksheet->setAutofilter();
$worksheet->setColWidthAuto(self::getColumnRange($headers));

Filter applied below:
image
image

Filter not applied below: (As u can see last character is not visible)
image

Desired result below by manually double-clicking between the two columns
image

Is this possible? PHPSpreadsheet does this very well

Here's an explanation of how PhpSpreadsheet calculates column width: PHPOffice/PhpSpreadsheet#2750

The GD method is definitely not suitable, because it will be very slow on large tables. The FastExcelWriter library is designed to create Excel files very quickly, and cannot use this method. But I will look into PhpSpreadsheet alternative method

Here's an explanation of how PhpSpreadsheet calculates column width: PHPOffice/PhpSpreadsheet#2750

The GD method is definitely not suitable, because it will be very slow on large tables. The FastExcelWriter library is designed to create Excel files very quickly, and cannot use this method. But I will look into PhpSpreadsheet alternative method

Ah I see, thank you for the explanation!
I suppose it's not possible to add extra width after this automatic calculation?

I have improved the column width calculation, please update to 5.3 and check it