I need to merge cells in Excel (xlsx) by rows and again by columns using PHPExcel. I tried the following.
$sheet->mergeCells(\"G\".($row_count+1).\":G\".($row
I make a simple function to calc cells to merge by cols and row.
function cellsToMergeByColsRow($start = NULL, $end = NULL, $row = NULL){
$merge = 'A1:A1';
if($start && $end && $row){
$start = PHPExcel_Cell::stringFromColumnIndex($start);
$end = PHPExcel_Cell::stringFromColumnIndex($end);
$merge = "$start{$row}:$end{$row}";
}
return $merge;
}
And call
$sheet->mergeCells(cellsToMergeByColsRow($col, $col+5, $row));
Thanks @Mark Baker