Open thenibirahmed opened 2 months ago
Hi,
WithCalculatedFormulas
concern is not working yet (it's a empty file in the /src/concerns/
directory), i had this problem a few days ago.
This is how I've fixed my problem:
public function onRow(Row $row)
{
$data = $row->toArray(null, true);
Adding null
and true
as parameters to toArray()
About it:
The
toArray()
method of theRow
class in Laravel Excel (which uses PhpSpreadsheet) converts a row from the spreadsheet into an array. This method can accept two optional parameters:
null
: This parameter is used to specify a custom header mapping. Ifnull
is passed, the default headers from the spreadsheet will be used.true
: This parameter indicates whether the formulas in the cells should be evaluated and the calculated values should be returned instead of the formulas themselves.
Maybe because you're using ToModel
, you need to adapt it somehow.
Hope this helps!
Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?
What version of Laravel Excel are you using?
3.1
What version of Laravel are you using?
11
What version of PHP are you using?
8.3
Describe your issue
In one file when I'm trying to read data by
It's getting with calculated formula
But when directly
The formulas are not calculated, returned empty strings.
Formula example:
=IF(Introduction!$D$41=""'"'',(1-Introduction!SD$41)*Prices!D9)
How can the issue be reproduced?
Just have a complex formula as I've given in examplethe
What should be the expected behaviour?
The value should be calculated