Php laravel excel库的UTF-8编码问题
我在项目中使用laravel excel库将刀片文件导出到excel文件。 我的网站语言是波斯语,UTF-8编码。我的问题是,当用户下载xls或csv文件时,它的字符不正确,而如果保存为xlsx的文件则什么也不显示。 这是我的刀片文件代码:Php laravel excel库的UTF-8编码问题,php,excel,laravel,utf-8,laravel-excel,Php,Excel,Laravel,Utf 8,Laravel Excel,我在项目中使用laravel excel库将刀片文件导出到excel文件。 我的网站语言是波斯语,UTF-8编码。我的问题是,当用户下载xls或csv文件时,它的字符不正确,而如果保存为xlsx的文件则什么也不显示。 这是我的刀片文件代码: <ul style="display: flex;justify-content: space-between;align-items: center;max-width: 800px; background-color:#ff008f;margin:
<ul style="display: flex;justify-content: space-between;align-items: center;max-width: 800px; background-color:#ff008f;margin: 0 auto;text-align: center; color:#fff;min-width:500px;">
<li style="display: inline-block;padding:8px 10px;width: 35px;">ردیف</li>
<li style="display: inline-block;padding:8px 10px;width: 200px;">نام مشتری</li>
<li style="display: inline-block;padding:8px 10px;width: 200px;">شماره فاکتور</li>
<li style="display: inline-block;padding:8px 10px;width: 200px;">تعداد</li>
<li style="display: inline-block;padding:8px 10px;width: 200px;">تاریخ ثبت</li>
<li style="display: inline-block;padding:8px 10px;width: 200px;">ساعت ثبت</li>
<li style="display: inline-block;padding:8px 10px;width: 200px;">مبلغ کل</li>
</ul>
<div>
<?php
$i=1;
foreach($fields as $field){
?>
<ul style="display: flex;justify-content: space-between;align-items: center;max-width: 800px;margin: 0 auto;text-align: center; color:#111;min-width:500px;">
<li style="display: inline-block;width: 35px;padding:8px 10px;"><?php echo $i?></li>
<li style="display: inline-block;width: 200px;padding:8px 10px;"><?php echo $user->name?></li>
<li style="display: inline-block;width: 200px;padding:8px 10px;"><?php echo $field->refid?></li>
<li style="display: inline-block;width: 200px;padding:8px 10px;"><?php echo $count?></li>
<li style="display: inline-block;width: 200px;padding:8px 10px;"><?php echo $jDate?></li>
<li style="display: inline-block;width: 200px;padding:8px 10px;"><?php echo $field->time?></li>
<li style="display: inline-block;width: 200px;padding:8px 10px;"><?php echo $field->total_fee?></li>
</ul>
<?php
$i++;
$array = [$fields,$user,$count];
}
public function exportXls(Request $request){
$fromDate = $request->input('fromDate');
$toDate=$request->input('toDate');
$fromDate = explode('/',$fromDate);
$fromGdate = jalali_to_gregorian($fromDate[2],$fromDate[1],$fromDate[0]);
$toDate = explode('/',$toDate);
$toGdate = jalali_to_gregorian($toDate[2],$toDate[1],$toDate[0]);
$fromTime = $request->input('fromTime');
$toTime = $request->input('toTime');
$data['fields'] = DB::table('z_orders')->whereBetween('date',array($fromGdate,$toGdate))->whereBetween('time',array($fromTime,$toTime))->get();
$data['without'] = false;
Excel::create('excelFile', function($excel) use($data) {
$excel->sheet('excelSheet', function($sheet) use($data) {
$sheet->loadView('admin.c-filter',$data);
});
})->download('xls');
return response()->json('YES');
}
我使用ajax请求调用exportXls函数。
这是这个图书馆向我展示的图片:
将
添加到视图或创建布局
<!DOCTYPE html>
<html lang="{{ \Lang::getLocale() }}">
<head>
<meta charset="utf-8">
</head>
<body>
@yield('content')
</body>
</html>
@产量(‘含量’)
将
添加到视图或创建布局
<!DOCTYPE html>
<html lang="{{ \Lang::getLocale() }}">
<head>
<meta charset="utf-8">
</head>
<body>
@yield('content')
</body>
</html>
@产量(‘含量’)
这对我很有用:
这对我很有用:
有人能帮我吗?有人能帮我吗?