Search code examples
excelxlsxphpspreadsheet

phpspreadsheet merge error with variables


When I'm merging cells with phpspreadsheet using a variable I have an issue.

On opening in MS Excel (2019), it says that the program can try to recover the document if I'm sure it's a reliable one.

When I say yes, the document is ok and the merging worked fine. Why do I have that message?

I don't have this message on this way :

$spreadsheet->getActiveSheet()->mergeCells('B2:F2');

But on this way I have this message :

$cellRange      =   'B2:F2';
$spreadsheet->getActiveSheet()->mergeCells($cellRange);

Solution

  • My mistake was : I was using that merging tool on a "for" loop and I was trying to merge an already merged cell with another one.