Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
Laravel Excel3.0如何导出_创想鸟

Laravel Excel3.0如何导出

                                                       

下面由Laravel教程栏目给大家介绍Laravel Excel3.0导出方法,希望对需要的朋友有所帮助!

导出方法抽离:

结束行]     * $columnName 需要合并列 与合并行数结合使用ARRAY存储 ['A','B']     */    public function __construct($row,$data,$mergeCell=null,$columnName=null,$formatNumber=[])    {        $this->row = $row;        $this->data = $data;        $this->mergeCell = $mergeCell;        $this->columnName = $columnName;        $this->formatNumber = $formatNumber;    }    public function collection()    {        $row = $this->row;        $data = $this->data;//设置表头        foreach ($row[0] as $key => $value) {            $key_arr[] = $key;        }//输入数据        foreach ($data as $key => &$value) {            $js = [];            for ($i=0; $i  $value[ $key_arr[$i] ] ]);            }            array_push($row, $js);            unset($val);        }        return collect($row);    }    public function registerEvents(): array    {        // TODO: Implement registerEvents() method.        if ($this->mergeCell && $this->columnName){            return [                AfterSheet::class => function(AfterSheet $event){                    foreach ($this->columnName as $column){                        foreach ($this->mergeCell as $key=>$value){                            $event->sheet->getDelegate()->mergeCells($column.$key.':'.$column.$value);                        }                    }                }            ];        }        return [];    }    public function columnFormats(): array{        $formatNumber = [];        foreach ($this->formatNumber as $column){            $formatNumber[$column] = NumberFormat::FORMAT_TEXT;        }        return $formatNumber;    }}

使用:

如知AI笔记 如知AI笔记

如知笔记——支持markdown的在线笔记,支持ai智能写作、AI搜索,支持DeepseekR1满血大模型

如知AI笔记 27 查看详情 如知AI笔记

/*表头表体都为二维数组*/$row=[['row1'=>'列1','row2'=>'列2']];/*与表头key对应,缺少数据报错*/$list=[['row1'=>'行1列1','row2'=>'行1列2'],['row1'=>'行2列1','row2'=>'行2列2']];/*将第一行到第三行,第五行到第七行的A,B,C列各自合并*/$mergeCell=[1=>3,5=>7];$columnName=["A","B","C"];/*数字过长的列转换格式防止科学计数*/$formatNumber=['A','B','C'];//上方A,B,C列都为示意,根据自己需求调整,对应EXCEL的列return Excel::download(new Export($row,$list,$mergeCell,$columnName,$formatNumber),'fileName');

以上就是Laravel Excel3.0如何导出的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/352324.html

赞 (0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
《溯回青空》莉莉角色介绍
上一篇 2025年11月5日 22:52:55
凯迪拉克推新购车权益 Costco会员购IQ锐歌最高省10万
下一篇 2025年11月5日 22:53:03

相关推荐

发表回复

登录后才能评论
关注微信