public function generateHeader()
{
$columns = $this->getVisibleColumns();
if (count($columns) == 0) {
return;
}
$sheet = $this->_objPHPExcelSheet;
$style = ArrayHelper::getValue($this->styleOptions, $this->_exportType, []);
$colFirst = self::columnName(1);
$this->_endCol = 0;
foreach ($this->getVisibleColumns() as $column) {
$this->_endCol++;
/**
* @var DataColumn $column
*/
$head = $column instanceof DataColumn ? $this->getColumnHeader($column) : $column->header;
$id = self::columnName($this->_endCol) . $this->_beginRow;
$cell = $sheet->setCellValue($id, $head, true);
// Apply formatting to header cell
$sheet->getStyle($id)->applyFromArray($style);
$this->raiseEvent('onRenderHeaderCell', [$cell, $head, $this]);
}
for ($i = $this->_headerBeginRow; $i < $this->_beginRow; $i++) {
$sheet->mergeCells($colFirst . $i . ":" . self::columnName($this->_endCol) . $i);
}
// Freeze the top row
$sheet->freezePane($colFirst . ($this->_beginRow + 1));
}