I want to align the cell value to the middle. My output looks like this:-
My expected output should be this:
I want every column to be in the center. I tried the following code:
$styleArray = [
'font' => [
'bold' => true,
],
'alignment' => [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
],
'fill' => [
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
'startColor' => [
'argb' => '0070C0',
],
'endColor' => [
'argb' => '0070C0',
],
],
];
$spreadsheet->getDefaultStyle()->getFont()->setSize(10);
I tried all the other attributes like HORIZONTAL_CENTER
, RIGHT
, LEFT
, JUSTIFY
, etc. How can I do this properly?