Laravel Excel html para excel conversão não funciona
Estou usando a versão Laravel 5.6 e laravel-excel.maatwebsite versão 3.1. Quero converter html para arquivo excel.
Na documentação oficial, eles não forneceram informações suficientes para converter as visualizações html em excel. Estou tendo dificuldades.
Bow é o código paraApp\Exports\AttendanceExport
<?php
namespace App\Exports;
use App\Models\Student\StudentAttendenceModel;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\FromCollection;
class AttendanceExport implements FromView {
protected $data = [];
public function __construct($data) {
$this->data = $data;
}
public function view(): View {
return view($this->data['file_path'], [
'data' => $this->data
]);
}
}
MY CONTROLLER CODE:Reports\ReportsFormProcessController
<?php
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 App\Models\Student\StudentAttendenceModel;
//EXCEL
use App\Exports\AttendanceExport;
use Maatwebsite\Excel\Facades\Excel;
class ReportsFormProcessController extends Controller {
public function __construct() {
parent::__construct();
}
protected function processStdAttendance($data) {
$excel_query = [
'file_name' => 'test.xlsx',
'sheet_name' => 'sheet 11',
'file_path' => 'reports.excel_templates.test',
'query_results' => $info_array['query_results'], //THIS AS A RESULT FROM DB
];
$attendanceExport = new AttendanceExport($excel_query);
return $attendanceExport->view();
}
}
@MY HTML TEMPLATE CONTÉM UMA TABELA ABAIXO
<!DOCTYPE html>
<html>
<title>HTML Tutorial</title>
<body>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
</body>
</html>
NÃO ESTOU OBRIGATÓRIO POR ERROS TAMBÉM NÃO ESTOU OBTENDO EXCEL FILE DOWNLOAD
DESDE JÁ, OBRIGAD / * EDITS * / ESTE CÓDIGO ABAIXO LOJA EXCELAR ARQUIVO EMSTORAGE/APP
PASTA
return (new AttendanceExport($excel_query))->store('student_attendance.xlsx');
MAS O CÓDIGO DO DOCUMENTO ABAIXO NÃO FAZ O DOWNLOAD DO ARQUIVO EXCEL.
return Excel::download(new AttendanceExport($excel_query), 'student_attendance.xlsx');// THIS DOES NOT DOWNLOAD