Great work, in v3.1: using WithMultipleSheets how to get an uploaded excel sheet name(s)? #Need more information
Thanks for submitting the ticket. Unfortunately the information you provided is incomplete. We need to know which version you use and how to reproduce it. Please include code examples. Before we can pick it up, please check (https://github.com/Maatwebsite/Laravel-Excel/blob/3.0/.github/ISSUE_TEMPLATE.md) and add the missing information. To make processing of this ticket a lot easier, please make sure to check (https://laravel-excel.maatwebsite.nl/docs/3.0/getting-started/contributing) and double-check if you have filled in the issue template correctly. This will allow us to pick up your ticket more efficiently. Issues that follow the guidelines correctly will get priority over other issues.
It depends what you want to use the sheet name for. You can use the BeforeSheet event and get it via that way perhaps. https://laravel-excel.maatwebsite.nl/3.1/imports/extending.html#events
It depends what you want to use the sheet name for. You can use the
BeforeSheetevent and get it via that way perhaps. https://laravel-excel.maatwebsite.nl/3.1/imports/extending.html#events
$event->getSheet() ? If I want to sheet name insert to DB, how to do ?
$event->getSheet()->getTitle() should work
@patrickbrouwers is it possible to do the following:
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
class ZImport implements WithMultipleSheets, WithEvents {
public function sheets(): array {
$sheets = [];
//get title here
if($event->getSheet()->getTitle() === 'X'){
$sheets[0] = new XImport();
}else{
$sheets[0] = new YImport();
}
return $sheets;
}
}
@patrickbrouwers is it possible to do the following:
use Maatwebsite\Excel\Concerns\WithMultipleSheets; class ZImport implements WithMultipleSheets, WithEvents { public function sheets(): array { $sheets = []; //get title here if($event->getSheet()->getTitle() === 'X'){ $sheets[0] = new XImport(); }else{ $sheets[0] = new YImport(); } return $sheets; } }
where is $event ?
@MahmoudAljabary @zishiguo
public function sheets(): array {
return [
'X' => new XImport(),
'Y' => new YImport(),
];
@patrickbrouwers I would like to import sheets conditionally/dynamically based on the sheet title.
@MahmoudAljabary Have Solved The Dynamic Conditional Based On The Title Sheet?
Any Progress?
@MahmoudAljabary @zymawy
Check out my approach to this https://github.com/Maatwebsite/Laravel-Excel/issues/1881#issuecomment-437280026
Most helpful comment
@MahmoudAljabary @zymawy
Check out my approach to this https://github.com/Maatwebsite/Laravel-Excel/issues/1881#issuecomment-437280026