내가 원하는 수입 Excel 하지만 시트 지수는[0],그러나 내가 사용하는 경우 toCollection 또는 toArray 방법 행 포장에서 시트 인덱스 array:
내가 원하는 제거한 포장 부모 배열,어떻게 하면 이렇게 할 수 있습니까?
여기에는 나의 코드:
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.***