4
對不起, 我想用laravel-excel導出我的報告。 這是控制器:laravel-excel不能導出xls文件使用刀片和圖像
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>
然後會出現這樣的錯誤:
PHPExcel_Exception
File http://myserver.com/projectname/public/assets/images/upload/DSCN1164.jpg not found!
當我嘗試在瀏覽器中訪問該文件時,該文件存在。
嘗試提供的圖像,而不是一個URL文件系統路徑:底層PHPExcel庫不會與URL一起工作,只能使用映像的文件系統路徑 – 2014-09-30 08:43:33