问题描述
使用 Laravel 8
我的路线:
Route::get('socios/export',[SocioController::class,'export'])->name('socios.export');
我的控制器方法:
public function export(Request $request)
{
$registros = User::socios()->get();
$content = view('socios.excel',compact('registros'));
$status = 200;
$headers = [
'Content-Type' => 'application/vnd.ms-excel; charset=utf-8','Content-Disposition' => 'attachment; filename="filename.xls"',];
$response = response($content,$status,$headers);
return $response;
}
我的“socios.excel”视图:
<table>
<thead>
<tr>
<th>ID</th>
<th>name</th>
<th>...</th>
</tr>
</thead>
<tbody>
@foreach ($registros as $registro)
<tr>
<td>{{ $registro->id }}</td>
<td>{{ $registro->name }}</td>
<td>...</td>
</tr>
@endforeach
</tbody>
</table>
文件导出正常,但像“Dirección”这样的字符串包含错误的字符:
我在内容类型标题中尝试了不同的字符集,但无法修复它。
需要帮助吗?
谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)