Reputation: 37
PHP - 7.4.33
Laravel - 6.20.44
maatwebsite/excel - 3.1.56
I have tried to use WithMultipleSheets
to import multi sheets from a excel, but it just use the first Import ZoneRuleImport
to all the sheet data. Is anything wrong?
$import = new CarrierPriceRuleImport($ruleId, $length);
Excel::import($import, $file);
class CarrierPriceRuleImport implements WithMultipleSheets, SkipsUnknownSheets
{
protected $ruleId, $length;
public function __construct($ruleId, $length = 5)
{
$this->ruleId = $ruleId;
$this->length = $length;
}
public function sheets(): array
{
return [
0 => new ZoneRuleImport($this->ruleId, $this->length),
1 => new ZonePriceImport($this->ruleId),
];
}
public function onUnknownSheet($sheetName)
{
dump($sheetName);
}
}
Upvotes: 1
Views: 37