Y
Y
Yuriy2019-04-02 16:46:29
phpspreadsheet
Yuriy, 2019-04-02 16:46:29

PhpSpreadsheet how to center an image in a cell?

PhpSpreadsheet Tell me how to place an image in a cell in the center?
the picture is smaller than the height of the cell, the cell should have center styles.

'alignment'=>[
'horizontal'=>\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,'vertical'=>\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER
  ],

and for some reason the picture runs over the neighboring BORDER
5ca3674d7321f733461500.png
, only the TEXT in this cell is centered...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuriy, 2019-04-02
@yous

I will answer myself))

$drawing->setOffsetX(($spreadsheet->getActiveSheet()->getColumnDimension('A1')->getWidth()-$drawing->getWidth())/2);
$drawing->setOffsetY(($spreadsheet->getActiveSheet()->getColumnDimension('A1')->getHeight()-$drawing->getHeight())/2);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question