Laravel Maatwebsite 导出到 excel 不工作
Laravel Maatwebsite Export to excel not working
我正在使用 Laravel 5.6 和 Laravel-Maat Excel 版本 3.1。尽管我参考了官方文档,但在将数据导出到 excel.
时仍然面临很多问题
下面是来自 git Click Here to view
的特定文档的 link
我正在尝试将一些数据导出到 excel file.But 我没有工作,而且他们没有显示任何错误。
下面是我的代码
php artisan make:export StudentAttendanceExport --model=Models\Student\StudentAttendenceModel
文件App\Exports\StudentAttendanceExport
<?php
namespace App\Exports;
use App\Models\Student\StudentAttendenceModel;
use Maatwebsite\Excel\Concerns\FromCollection;
class StudentAttendanceExport implements FromCollection
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return StudentAttendenceModel::all();
}
}
在我的控制器中Reports\ReportsFormProcessController
namespace App\Http\Controllers\Reports;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
use App\Models\Student\StudentAttendenceModel;
//EXCEL
use App\Exports\StudentAttendanceExport;
use Maatwebsite\Excel\Facades\Excel;
class ReportsFormProcessController extends Controller {
public function __construct() {
parent::__construct();
}
protected function processStdAttendance($data) {
return Excel::download(new StudentAttendenceModel, 'users.xlsx');
}
}
在上面LINK他们说Find your users.xlsx in your downloads folder!
但是在哪个路径中已经搜索了所有目录但仍然没有找到它。
提前致谢
使用 [=h11=] 代替 StudentAttendenceModel
protected function processStdAttendance($data) {
return Excel::download(new StudentAttendanceExport, 'users.xlsx');
//return Excel::download(new StudentAttendenceModel, 'users.xlsx');
}
我正在使用 Laravel 5.6 和 Laravel-Maat Excel 版本 3.1。尽管我参考了官方文档,但在将数据导出到 excel.
时仍然面临很多问题下面是来自 git Click Here to view
的特定文档的 link我正在尝试将一些数据导出到 excel file.But 我没有工作,而且他们没有显示任何错误。
下面是我的代码
php artisan make:export StudentAttendanceExport --model=Models\Student\StudentAttendenceModel
文件App\Exports\StudentAttendanceExport
<?php
namespace App\Exports;
use App\Models\Student\StudentAttendenceModel;
use Maatwebsite\Excel\Concerns\FromCollection;
class StudentAttendanceExport implements FromCollection
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return StudentAttendenceModel::all();
}
}
在我的控制器中Reports\ReportsFormProcessController
namespace App\Http\Controllers\Reports;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
use App\Models\Student\StudentAttendenceModel;
//EXCEL
use App\Exports\StudentAttendanceExport;
use Maatwebsite\Excel\Facades\Excel;
class ReportsFormProcessController extends Controller {
public function __construct() {
parent::__construct();
}
protected function processStdAttendance($data) {
return Excel::download(new StudentAttendenceModel, 'users.xlsx');
}
}
在上面LINK他们说Find your users.xlsx in your downloads folder!
但是在哪个路径中已经搜索了所有目录但仍然没有找到它。
提前致谢
使用 [=h11=] 代替 StudentAttendenceModel
protected function processStdAttendance($data) {
return Excel::download(new StudentAttendanceExport, 'users.xlsx');
//return Excel::download(new StudentAttendenceModel, 'users.xlsx');
}