$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');
}
}
}