excel - 如何从excel文件中读取数据并显示在我的 View 中?

标签 excel laravel

在我的 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/

相关文章:

php - Redis 是否可以像 PHP 中的 MySQL 一样查询?

php - 无法安装,当前用户无法写入 channel "pecl.php.net"的 php_dir

javascript - Laravel 删除按钮不适用于 Ajax 调用

excel - 将两个不同工作簿中的两个范围粘贴到 Outlook 邮件正文中

Excel 英尺和英寸到毫米

Python 将结果保存到 .xls 文件给出错误

java - 在java中写入Excel中的特定单元格

vba - 如何存储一个可以在多个事件调用中使用的对象?

php - 具有两个外键的三个表之间的 Laravel 关系

laravel - 如何在 AWS Elastic BeanStalk 上配置和运行 crontab?