मैं चाहता हूँ आयात एक्सेल लेकिन केवल पर चादर सूचकांक[0], लेकिन जब मैं का उपयोग toCollection या toArray विधि पंक्तियों पर लिपटे चादर सूचकांक सरणी:
मैं करना चाहते हैं को दूर लिपटे माता-पिता सरणी, यह कैसे करना है?
यहाँ है मेरे कोड:
Import.php
<?php
namespace App\Imports;
use Maatwebsite\Excel\Concerns\Importable;
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
use Maatwebsite\Excel\Concerns\WithCalculatedFormulas;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
class Import implements SkipsEmptyRows,
WithCalculatedFormulas,
WithMultipleSheets
{
use Importable;
/**
* Select sheet by index and how they are
* mapped to specific import object.
*
* @return array
*/
public function sheets(): array
{
return [
0 => new static(),
];
}
}
नियंत्रक:
$filePath = 'import-excel.xlsx';
$import = new Import();
$rows = $import->toCollection($filePath);
dd($rows->toArray());
अपेक्षित परिणाम:
[0] => Array(
[0] => *Contact Name
[1] => *Contact Email
[2] => *Contact Address
)
[1] => Array (
[0] => Talia Oktaviani S.Psi
[1] => [email protected]
[2] => Ds. Abdul No. 618 Tarakan 11408 KalU
)
वास्तविक परिणाम:
Array( <== ***I want remove this.***
[0] => Array( <== ***I want remove this.***
[0] => Array(
[0] => *Contact Name
[1] => *Contact Email
[2] => *Contact Address
)
[1] => Array (
[0] => Talia Oktaviani S.Psi
[1] => [email protected]
[2] => Ds. Abdul No. 618 Tarakan 11408 KalU
)
) <== ***I want remove this.***
) <== ***I want remove this.***