PhpExcel: center alignment of text in one cell in a set of merged cells

I am using PHPExcel to create an xls file. I merged cells (B2: E2), but I want the text entered in B2 to be horizontally centered only in cell B2. It is centered in the merged cell.

$sheet_obj->getStyle('B2')->getAlignment()->setHorizontal(
    PHPExcel_Style_Alignment::HORIZONTAL_CENTER
);
+4
source share
1 answer

hope this helps

$sheet_obj->getActiveSheet()->getStyle('G2') ->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);

0
source

All Articles