1

version

PHP - 7.4.33

Laravel - 6.20.44

maatwebsite/excel - 3.1.56

Description

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?

Code

$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);
    }
}

Excel

enter image description here

Running

enter image description here

2
  • can you try removing the indexes 0, 1 from your list. It may be trying to match that with the name of the sheet Commented Jan 16 at 17:02
  • I have tried removing the number index or using the sheet name , and its all not work Commented Jan 17 at 3:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.