Php laravel excel无法使用带图像的刀片导出xls文件
对不起, 我想使用laravel excel导出我的报告。 这是控制器:Php laravel excel无法使用带图像的刀片导出xls文件,php,html,excel,laravel,laravel-excel,Php,Html,Excel,Laravel,Laravel Excel,对不起, 我想使用laravel excel导出我的报告。 这是控制器: public function getExcelfile(){ $users = UserService::findAllPublic(); $total = UserService::count(); $total_with_photo = UserService::countWithPhoto(); Excel::create('excelfile', f
public function getExcelfile(){
$users = UserService::findAllPublic();
$total = UserService::count();
$total_with_photo = UserService::countWithPhoto();
Excel::create('excelfile', function($excel) use ($users, $total, $total_with_photo) {
$excel->sheet('Excel', function($sheet) use ($users, $total, $total_with_photo) {
$sheet->loadView('report.excel')->with("users", $users)->with("total", $total)->with("total_with_photo", $total_with_photo);
});
})->export('xls');
}
这是位于报告文件夹中的excel.blade.php:
<html> <body> Total Registered User : {{$total}} Total Registered User With Photo : {{$total_with_photo}} <h1>Data User</h1> @if(!empty($users)) <table class="table table-striped table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Photo</th>
<th>Nama</th>
<th>Struck</th>
<th>Email</th>
<th>Phone</th>
<th>FB ID</th>
<th>Timestamp</th>
<th>Publish</th>
</tr>
</thead>
@foreach ($users as $row)
<tr>
<td>{{$row->id}}</td>
<td><img src="{{URL::asset('assets/images/upload/' . $row->photo)}}" width="200px"/></td>
<td>{{$row->nama}}</td>
<td>{{$row->struck}}</td>
<td>{{$row->email}}</td>
<td>{{$row->phone}}</td>
<td>{{$row->fbid}}</td>
<td>{{$row->timestamp}}</td>
<td>{{$row->publish}}</td>
</tr>
@endforeach </table> @endif </body> </html>
当我尝试在浏览器中访问该文件时,该文件已存在。而不是:
<img src="{{URL::asset('assets/images/upload/' . $row->photo)}}"
photo)}”
你应使用:
<img src="assets/images/upload/{{{ $row->photo }}}"
photo}”
当然,假设它是正确的路径请尝试提供映像的文件系统路径,而不是URL:底层PHPExcel库不能使用URL,只能使用映像的文件系统路径
<img src="assets/images/upload/{{{ $row->photo }}}"