Laravel-excel: [BUG] WithCalculatedFormulas does not work with OnEachRow

Created on 1 Apr 2020  路  3Comments  路  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
  • Laravel version: 6.x
  • Package version: 3.1

Description

WithCalculatedFormulas doesn't appear to work with OnEachRow.

Steps to Reproduce

  • Create an Import class
  • add implements OnEachRow, WithCalculatedFormulas to class
  • Run the import and observe the formula is not calculated
  • Then open ~/vendor/maatwebsite/excel/src/Cell.php and find public function getValue($nullValue = null, $calculateFormulas = false, $formatData = true). Force $calculateFormulas = true
  • Run the import and observe the formula is now calculated

Expected behavior:

Implementing WithCalculatedFormulas should set $calculateFormulas = true

Actual behavior:

The original Excel formula is imported

bug

Most helpful comment

Hi @949mac ,
I think in the function onRow, you have to pass the $calculateFormulas option to $row->toArray(null, true).

All 3 comments

If you could provide a failing tests that would be useful to understand what's going wrong

Hi @949mac ,
I think in the function onRow, you have to pass the $calculateFormulas option to $row->toArray(null, true).

Hello @ngocongcan,

Ah, beautiful! Thank you very much.

Best Regards,

Mike

Was this page helpful?
0 / 5 - 0 ratings