As Mark noted in the comments; a merged cell is structural, not stylish. Therefore, copying a style will not automatically copy the merged cells.
There is a function request to be able to duplicate whole rows, including merged cells
One way to handle this is to check if the cells are part of the merge using the isInMergeRange() function as follows:
$workbook = new PHPExcel; // prepare the workbook $sheet = $workbook->getActiveSheet(); // get the sheet $sheet->mergeCells('A1:E1'); // merge some cells for tesing $cell = $sheet->getCell('A1'); // get a cell to check if it is merged $cell->isInMergeRange() // check if cell is merged
^ This returns a boolean value indicating whether it is part of a merged cell.
Another function that might interest you is the isMergeRangeValueCell() function:
$cell->isMergeRangeValueCell()
^ This returns a boolean value indicating that it is part of a merged cell and , the cell contains a value for the merged range; it returns false in all other situations.
Tim penner
source share