Replies: 2 comments 4 replies
-
Perhaps have a look at this unit test we have: https://github.com/Maatwebsite/Laravel-Excel/blob/3.1/tests/Concerns/WithMappedCellsTest.php#L64 Perhaps it will help you find a solution |
Beta Was this translation helpful? Give feedback.
-
Sorry to bump in on this, but could it be that the WithMapping concern cannot be used in combination with the WithMappedCells concern ? I think It actually makes sense if this is indeed the case. I did however stumble on a similar issue where I need to map one row's value to a 'hard coded' cell location in combination with dynamic mappings (and WithHeadingRow). I think this is a very specific edge case scenario, that is indeed not covered in the test cased you referenced. The csv could look like this:
I will try to write a (failing) test. public function map($row): array
{
return [
'username' => someMethodToResolve('B1'),
'id' => $row['ID'],
'name' => $row['NAME'],
];
} Highest regards, |
Beta Was this translation helpful? Give feedback.
-
I am trying to get the value of some cells in a sheet from an excel file. According to the docs (https://docs.laravel-excel.com/3.1/imports/mapped-cells.html) I need to use
WithMappedCells
and their example code is:Here is my spreadsheet:
In my import file I have this mapping
On their github I found this solution: #1836 (comment)
However, this still tried to add it to a Model. I noticed that it used
$row
So I tried is this:But I get this error:
How do I simple get those values from those specific cells so I can perform some checks on them?
Edit: When I log out just
$row
I get:As you can see, the data is there but the mapping is not correct. I have checked and I am using :
at the top of my file and am making sure my class implements these:
Beta Was this translation helpful? Give feedback.
All reactions