导出的表格按照字段字数设置宽度

This commit is contained in:
2022-12-09 17:14:29 +08:00
parent e17eca274f
commit 48e01344d7

View File

@@ -17,6 +17,7 @@ class ExportTools
foreach ($fields as $field_key => $field_name) {
$col_key = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($write_col);
$sheet->setCellValue($col_key . $write_line, $field_name);
$sheet->getColumnDimension($col_key)->setWidth(mb_strlen($field_name) * 3);
$write_col++;
}