0
행 데이터가 다른 경우 독자가 Excel 파일을 읽지 못하도록하는 방법이 있습니까? 엑셀 파일을 업로드 할 때 Undefined index: description
이 나오면 업로드 된 파일에서 description
을 찾을 수 없습니다.정의되지 않은 색인 : 설명 - Excel 파일 업로드
이 오류를 처리 할 수있는 방법이 있습니까? (! $ 행 [ '설명']) :
if ($request->file('imported-file')) {
$path = $request->file('imported-file')->getRealPath();
$data = Excel::load($path, function($reader) {
$reader->calculate(false);
})->get();
if (($request->file('imported-file')->getClientOriginalExtension()) != 'xlsx') {
return redirect('')->with('error','File Format may not be supported');
} else {
if (!empty($data) && $data->count()) {
foreach ($data->toArray() as $row) {
if (!empty($row)) {
$dataArray[] = [
'name' => $row['name'],
'description' => $row['description'],
];
}
}
if (!empty($dataArray)) {
Item::insert($dataArray);
return redirect('')->with('status','successfully added');
}
}
}
}
'경우를 사용할 수 있습니다 – Tpojka