Yii2 Kartik Export with sub header

Yii2 Kartik Export with sub header

如何使用 kartik 导出创建多个 header(子 header),如下面的 table 我猜想使用 onRenderHeaderCell=>function($cell, $content, $widget){} 函数 https://demos.krajee.com/export#option-onRenderHeaderCell,但还是失败了

我不会使用headercells。我会用平面格式化命令来格式化。像这样:

$spreadsheet->getActiveSheet()->mergeCells('B1:C1');
$spreadsheet->getActiveSheet()->mergeCells('F1:G1');
$spreadsheet->getActiveSheet()->mergeCells('A1:A2');
$spreadsheet->getActiveSheet()->mergeCells('D1:D2');
$spreadsheet->getActiveSheet()->mergeCells('E1:E2');
$spreadsheet->getActiveSheet()->getStyle("A1")->getFont()->setBold(true);
$spreadsheet->getActiveSheet()->getStyle("B1")->getFont()->setBold(true);
$spreadsheet->getActiveSheet()->getStyle("D1")->getFont()->setBold(true);
$spreadsheet->getActiveSheet()->getStyle("E1")->getFont()->setBold(true);
$spreadsheet->getActiveSheet()->getStyle("F1")->getFont()->setBold(true);
$spreadsheet->getActiveSheet()->getStyle("B2")->getFont()->setBold(true);
$spreadsheet->getActiveSheet()->getStyle("C2")->getFont()->setBold(true);
$spreadsheet->getActiveSheet()->getStyle("F2")->getFont()->setBold(true);
$spreadsheet->getActiveSheet()->getStyle("G2")->getFont()->setBold(true);

小心合并单元格。您应该只格式化 headcell。