PhpSpreadsheet导出Excel表格,长数字自动转科学计数法

正文开始

 $sheet->getCell('A1')->setValueExplicit(12322323,'s');

https://cloud.tencent.com/developer/article/1556289?areaId=106001

我的案例:

  $mustStringArray = ['E', 'H'];
        foreach ($list as $key => $item) {             //循环设置单元格:
            //$key+2,因为第一行是表头,所以写到表格时   从第二行开始写
            foreach ($head as $n => $trArray_) {
                $currentColumn = $stringFromColumnIndex($n);
                $sheet->setCellValue($currentColumn . ($key + 2), $item[$trArray_[1]]);

                if (in_array($currentColumn, $mustStringArray)){

                    $sheet->getCell($currentColumn . ($key + 2))->setValueExplicit($item[$trArray_[1]],'s');
                }
            }

        }

正文结束

PHP接口(interface)和抽象类(abstract) 没有上一篇