A
A
Andrey Sobolev2020-04-21 14:16:53
PHP
Andrey Sobolev, 2020-04-21 14:16:53

Why is cell color not being set in PHP Spreadsheet?

Trying out the code

$worksheet->getCell('B1')->getStyle()->getFill()->getStartColor()->setARGB('FFF5F2DD');

Not set. Still a white box. Tried using applyFromArray - not suitable /
Tell me how to change the color of the cell?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daria Motorina, 2020-04-21
@andrufka46rus

You need to add the SetFillType method

$sheet->getStyle('B1')
            ->getFill()
            ->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
            ->getStartColor()
            ->setARGB('FFF50000');

Taken from here :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question