将自定义网站 excel 与用户磨砂一起使用

Using maatwebsite excel with userfrosting

我正在尝试导出自定义数据,这些数据将被馈送到 userfrosting 中的数据表中。我已经使用 composer 加载了 maatwebsite excel 库并且更新了 autoload_classmap.php。 在控制器中,我尝试使用以下内容:

Excel::create('master',function($excel) use($events){                    
    $excel->sheet('Master List', function($sheet) use($events){          
        $sheet->fromArray($events);                                      
    });                                                                  
})->export('xls'); 

当我 运行 这样做时,出现以下错误:

PHP Fatal error:  Class 'UserFrosting\Excel' not found in /usr/www

我查看了 laravel 示例并进行了尝试,它们没有问题。但是我需要这个来处理 userfrosting,因为应用程序已经并且只是缺少导出。

这听起来像是命名空间问题。尝试:

\Maatwebsite\Excel\Excel::create(...

请注意,我为 Excel class 使用了完全限定的命名空间。

我最终离开 maatwebsite/excelphpoffice/phpexcel,这对我来说工作得更快一些,我会在不久的将来尝试得到这个问题的答案。