by Guest » 16 Jan 2025, 08:35
Version
PHP – 7.4.33
Laravel – 6.20.44
maatwebsite/excel - 3.1.56
Beschreibung
Ich habe versucht, WithMultipleSheets zu verwenden, um mehrere Blätter aus Excel zu importieren, aber es verwendet einfach das Erster Import ZoneRuleImport auf alle Blattdaten. Stimmt etwas nicht?
Code
Code: Select all
$import = new CarrierPriceRuleImport($ruleId, $length);
Excel::import($import, $file);
Code: Select all
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);
}
}
Excel
Laufen

Version
PHP – 7.4.33
Laravel – 6.20.44
maatwebsite/excel - 3.1.56
Beschreibung
Ich habe versucht, WithMultipleSheets zu verwenden, um mehrere Blätter aus Excel zu importieren, aber es verwendet einfach das Erster Import ZoneRuleImport auf alle Blattdaten. Stimmt etwas nicht?
Code
[code]$import = new CarrierPriceRuleImport($ruleId, $length);
Excel::import($import, $file);
[/code]
[code]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);
}
}
[/code]
Excel
[img]https://i.sstatic.net/gjE5bkIz.png[/img]
Laufen
[img]https://i.sstatic.net/3GNpiPHl. png[/img]