【发布时间】:2018-02-02 03:45:21
【问题描述】:
我想在 laravel 中使用分页将表格中的数据导出到 excel 怎么做?我在 Github 中使用 Maatwebsite。
我在刀片中的分页表
<form method="GET" action="{{route('excelexport')}}">
<div style="float: right;margin-top: -12px;">
<button type="submit" class="btn btn-outline-primary">
<i class="icon-file-excel"></i> Export to Excel
</button>
</div>
</form>
<table cellpadding="10px" width="100%" class="table_str">
<thead style="font-size: 11px;">
<tr>
<th>col1 </th>
<th>col2 </th>
<th>col3 </th>
<th>col4 </th>
<th>col5 </th>
<th>col6 </th>
<th>col7 </th>
</tr>
</thead>
<tbody style="font-size: 11.5px;">
@foreach($result as $vals)
<tr scope="row" style="border-bottom: solid 1px #ccc">
<td>>{{$vals->fixass_id}}</a></td>
<td>{{$vals->brand_name}}</td>
<td>{{$vals->model_name}}</td>
<td>{{$vals->branch_name}}</td>
<td>{{$vals->dep_name}}</td>
<td>{{$vals->type}}</td>
<td>{{$vals->condition}}</td>
</tr>
@endforeach
</tbody>
</table>
{{ $result->links('pagination.default') }}
我的路线:
Route::get('excelexport','ReportController@createexcel')->name('excelexport');
我的控制器
public function createexcel(){
Excel::create('Report_Inventory', function ($excel) {
$excel->sheet('All Record', function ($sheet) {
$sheet->rows(array(array('Fixasset', 'Service tag', 'Brand', 'Model', 'CPU', 'HDD', 'RAM', 'IP','Window','System Type','Fullname')
))->freezeFirstRow();
});
})->export('xls');
}
如何将这些表中的数据导出到excel?
【问题讨论】:
标签: php laravel laravel-5.3 maatwebsite-excel