在我的 Controller 中,单击按钮时我将加载 excel 文件。
Excel::load(Input::file('import_file')->getRealPath(), function ($reader) use($arr){
// How can i get the $reader data and pass back to view?
});
return redirect()->back()->with('reader',...);
在我看来,我将显示从 excel 文件中获取的数据
@if(!empty(Session::get('reader')))
$(function() {
@foreach(session()->get('reader') as $key=>$row)
alert('{{$row['id']}}');
@endforeach
});
@endif
任何人都可以指导我如何将数据传递回 View ?
最佳答案
您直接将结果存储到数组中。所以你的代码应该像
$reader= \Excel::load(Input::file('import_file'))->toArray();
return redirect()->back()->with('reader', $reader);
关于excel - 如何从excel文件中读取数据并显示在我的 View 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45749438/