laravel Excel export 问题请教

在使用过程中 php版本7.2
使用格式csv 合并单元格不生效(styles 实现) 使用格式xls 则是乱码
php7.3 使用格式csv 合并单元格不生效(styles 实现) 使用格式xls 则可以生效
请问有大佬知道什么原因吗?谢谢Thanks♪(・ω・)ノ

部分代码附下:

<?php

namespace App\Exports\Banker\Traffic;

use App\Http\Controllers\JsLibController;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Concerns\WithTitle;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class TrafficProcurementExport implements FromCollection, WithHeadings, WithMapping,WithTitle,WithColumnWidths,WithStyles
{
    protected $data;
    protected $title;
    protected $time;
    protected $count;
    protected $count_order_amount;
    protected $trafficResourceTypeContent;

    public function __construct($data,$title = '',$time,$count,$count_order_amount,$trafficResourceTypeContent)
    {
        $this->data = $data;
        $this->title = $title;
        $this->time = $time;
        $this->count = $count;
        $this->count_order_amount = $count_order_amount;
        $this->trafficResourceTypeContent = $trafficResourceTypeContent;
    }

    /**
     * 样式设置
     */
    public function styles(Worksheet $sheet){
        $sheet->getDefaultRowDimension()->setRowHeight(22);//设置行高
        $sheet->getStyle('A1:U1')->getAlignment()->setVertical('center');//垂直居中
        $sheet->getStyle('A1:U1')->applyFromArray(['alignment' => ['horizontal' => 'center']]);//设置水平居中
        $sheet->getStyle('A1:U1')->applyFromArray(['font' => ['bold' => true, 'color' => ['rgb' => '0072ff']]]);//字体设置
        $sheet->mergeCells('A1:U1'); //合并单元格
        $sheet->mergeCells('C2:I2'); //合并单元格
        $sheet->mergeCells('J2:K2'); //合并单元格
        $sheet->mergeCells('M2:R2'); //合并单元格
    }
}
 return Excel::download(new TrafficProcurementExport(collect($resultArray),'测试',$time,count($result),$count_order_amount,$trafficResourceTypeContent),'traffic_procurement.csv');
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 1

同问,这个搞了很久但是都不生效也不知道是配置问题还是什么。

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!