Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Excel image change size

Tags:

php

xls

phpexcel

Developing PHP code that will create Excel file using PHP Excel.

I need to place an image into XLS file. Problem I have is that dimension of the image are not the one I defined in my code:

$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Water_Level');
$objDrawing->setDescription('Water_Level');
$objDrawing->setPath('img/logo-rab.jpg');
$objDrawing->setHeight(74);
$objDrawing->setCoordinates('A1');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());

This image is much higher than 74 pixels. Tried to add height and width also, but always the same.

Can you help me how to add image in my XLS, with dimensions I defined in PHP code?

Thank you in advance!

like image 864
user198003 Avatar asked Jul 09 '12 23:07

user198003


1 Answers

Have you tried using setWidthAndHeight and set ResizeProportional true?

$objDrawing->setWidthAndHeight(148,74);
$objDrawing->setResizeProportional(true);
like image 199
Fedy Venom Avatar answered Sep 16 '22 19:09

Fedy Venom