master
cody 3 months ago
parent d45e832207
commit b4ed7d943c

@ -292,6 +292,16 @@ class CommonExport implements FromCollection, WithStyles, WithColumnWidths, With
$endCol = $this->getColumnLetter($index + count(self::USERS_SUB_COLUMNS) - 1);
$sheet->mergeCells("{$startCol}1:{$endCol}1");
$sheet->setCellValue("{$startCol}1", $label);
// 确保第二行表头正确设置所有子列(包括缺失的列)
$subIndex = 0;
foreach (self::USERS_SUB_COLUMNS as $subField => $subLabel) {
$col = $this->getColumnLetter($index + $subIndex);
// 直接设置第二行表头,确保所有列都有值
$sheet->setCellValue("{$col}2", $subLabel);
$subIndex++;
}
$index += count(self::USERS_SUB_COLUMNS);
} elseif (str_contains($field, 'project_users')) {
// 项目经理信息列:合并第一行的多个单元格
@ -299,6 +309,15 @@ class CommonExport implements FromCollection, WithStyles, WithColumnWidths, With
$endCol = $this->getColumnLetter($index + count(self::PROJECT_USERS_SUB_COLUMNS) - 1);
$sheet->mergeCells("{$startCol}1:{$endCol}1");
$sheet->setCellValue("{$startCol}1", $label);
// 确保第二行表头正确设置所有子列
$subIndex = 0;
foreach (self::PROJECT_USERS_SUB_COLUMNS as $subField => $subLabel) {
$col = $this->getColumnLetter($index + $subIndex);
$sheet->setCellValue("{$col}2", $subLabel);
$subIndex++;
}
$index += count(self::PROJECT_USERS_SUB_COLUMNS);
} elseif (str_contains($field, 'history_courses')) {
// 历史课程信息列:合并第一行的多个单元格
@ -306,6 +325,15 @@ class CommonExport implements FromCollection, WithStyles, WithColumnWidths, With
$endCol = $this->getColumnLetter($index + count(self::HISTORY_COURSES_SUB_COLUMNS) - 1);
$sheet->mergeCells("{$startCol}1:{$endCol}1");
$sheet->setCellValue("{$startCol}1", $label);
// 确保第二行表头正确设置所有子列
$subIndex = 0;
foreach (self::HISTORY_COURSES_SUB_COLUMNS as $subField => $subLabel) {
$col = $this->getColumnLetter($index + $subIndex);
$sheet->setCellValue("{$col}2", $subLabel);
$subIndex++;
}
$index += count(self::HISTORY_COURSES_SUB_COLUMNS);
} else {
// 其他列:合并第一行和第二行

Loading…
Cancel
Save