im searching for hours in doc but got nothing to merge and horizontal center..
anyone can help me how to do this?
my last code :
$spreadsheet = new Spreadsheet();
$excel = $spreadsheet->getActiveSheet();
$spreadsheet->getProperties()->setTitle($name_sheet)->setCreator('Creator');
$excel->mergeCells('A1:W1');
$excel->mergeCells('A2:W2');
$excel->mergeCells('A3:W3');
//how to make cells A1 till W1 to be centered cell?
This is how y centered all the cells and format all borders.
$last_row = count($data) + 6;
$sheet->getStyle('A5:Y' . $last_row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
$sheet->getStyle('A5:Y' . $last_row)->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
$borders = [
'borders' => [
'allBorders' => [
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
'color' => ['argb' => '000'],
],
],
];
$sheet->getStyle('A5:Y' . $last_row)->applyFromArray($borders);