Laravel-excel: [BUG] - ShouldAutoSize Doesn't working on version 3.1.27

Created on 3 Mar 2021  路  4Comments  路  Source: Maatwebsite/Laravel-Excel

Prerequisites

  • [X] Checked if your Laravel Excel version is still supported: https://docs.laravel-excel.com/3.1/getting-started/support.html#supported-versions
  • [X] Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • [X] Checked that your issue isn't already filed.
  • [X] Checked if no PR was submitted that fixes this problem.
  • [X] Filled in the entire issue template

Versions

  • PHP version: 7.2.34
  • Laravel version: 5.8.38
  • Package version: 3.1.27

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
image

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...

bug

All 4 comments

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?

Was this page helpful?
5 / 5 - 1 ratings