Closed CarlosHLavezo closed 3 years ago
Can you create a PR for that?
No need anymore, I've pushed the fix myself. Thanks for reporting!
Oh! Thanks! I thought about opening the PR, but I decided to open this Issue before to validate... Anyway, I would like thanks for your attention.
@patrickbrouwers could we get a new release tagged now that this is fixed?
i have the same problem with ShouldAutoSize but i resolve it using those steps
1- go to vendor/maatwebsite/excel/src/Sheet.php
2-find function autoSize() and replace it with function below
// Edited function
public function autoSize()
{
foreach ($this->buildColumnRange('A', $this->worksheet->getHighestDataColumn()) as $col) {
$dimension = $this->worksheet->getColumnDimension($col);
// Only auto-size columns that have not have an explicit width.
if ($dimension->getWidth() === -1) {
$dimension->setAutoSize(true);}
elseif($dimension->getWidth() === -1.0){
$dimension->setAutoSize(true);
}
}
}
Prerequisites
Versions
Description
I was trying to use auto size in my sheet and it didn't work
Steps to Reproduce
Use the interface ShouldAutoSize in your sheet.
Expected behavior: The columns in the sheet will auto size the width
Actual behavior: The columns didn't auto size
Additional Information
I saw in the file vendor/maatwebsite/excel/src/Sheet.php the function below
It test if ($dimension->getWidth() === -1) { but the function getWidth() return a float type, when I changed it for if ($dimension->getWidth() === -1.0) { the auto sizing start working again...