[英]Get all the rows except for the fields Laravel: Excel
So I have an excel file with a format like this所以我有一个格式像这样的 excel 文件
I'm trying to get all the rows below the row1
我正在尝试获取row1
下面的所有行
This would be the records of John Doe
and Mc Doe
这将是John Doe
和Mc Doe
的记录
Currently I have this code from controller
目前我有来自controller
的代码
$dateTime = date('Ymd_His');
$file = $request->file('file');
$fileName = $dateTime . '-' . $file->getClientOriginalName();
$savePath = public_path('/upload/projectlist/');
$file->move($savePath, $fileName);
$excel = Importer::make('Excel');
$excel->load($savePath.$fileName);
$collection = $excel->getCollection();
if(sizeof($collection[1]) == 5){
for($row=1; $row<sizeof($collection); $row++){
try{
dd($collection[$row]);
}
catch(\Exception $e){
return redirect()
->back()
->with(['errors'=>$e->getMessage()])
->with('modal',$modal);
}
}
}else{
return redirect()
->back()
->with(['errors'=> [0=> 'Please provide date in file according to your format.']])
->with('modal',$modal);
}
And this gives me an output like this这给了我一个像这样的 output
Which the record of John Doe
only.只有John Doe
的记录。 How can I get all the rows except for row1
?如何获取除row1
之外的所有行?
here you get all the value if remove dd & it save every row in a array & dd that array outside the for loop then you get all results在这里,如果删除 dd 并且将每一行保存在数组中并在 for 循环之外 dd 该数组,则您将获得所有值,然后您将获得所有结果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.