Please ... I am new at laravel I want to export my view to excel with maatwebsite... I have tried many ways but I can not find the solution could you help me...?
My route
Route::get('index/{id}', ['as' => 'pagina', 'uses' =>'ExcelController@index']);
my link
<a class="btn btn-success" href="">Excel</a>
my view
<div class="panel-body">
<table class="table table-striped table-condensed table-responsive table-bordered">`
<thead>
<tr>
<th>Nombre</th>
<th>Pais</th>
<th>Tipo</th>
<th>CC_PMC</th>
</tr>
</thead>
<tbody>
@foreach($results as $result)
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
@endforeach
</tbody>
</table>
<a class="btn btn-success" href="">Excel</a>
</div>
and finally.. my controller (ExcelController)
class ExcelController extends Controller {
public function index($id){
Excel::create('New file', function($excel) use($id) {
$excel->sheet('New sheet', function($sheet) use($id) {
$sheet->loadView('listados.listados', ['results' => $id->toArray()]);
});
})->download('xls');
}
}
because it does not work ...? please help...!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire