Center Image in cell

Topics: Developer Forum, User Forum
Feb 10, 2012 at 11:07 AM

Hi all,

I'm trying to center an image in a cell but cannot find a solution in the documentation or search results.
Does any of you know how to properly align an image in the center of a cell (which ofcourse is wider than the image)

PHPExcel 1.7.6
PHP 5.2.14

Here's my current code

// Create new picture object
  $objDrawing = new PHPExcel_Worksheet_Drawing();

// Insert picture
// Style cell


Thank you for your help!

Feb 11, 2012 at 2:53 PM

Images don't actually exists within a cell, they're overlaid "above" the worksheet, so identifying a cell coordinate is a generalised way of positioning the image at a set position within the worksheet. Actually trying to position the image so that it appears to lie centred inside a cell is close to impossible, and well outside of the capabilities of PHPExcel.

Sep 25, 2012 at 6:11 AM


iam trying for that code..

but i have problem,there is an error..

Call to a member function getActiveSheet() on a non-object

any can help me?

thanks befeore :D