When using PHPExcel, why is the autosize stretching my image?

Topics: Developer Forum
Aug 3, 2013 at 7:07 AM
I am creating a spreadsheet using the PHPExcel Class. I have several columns of data. I am using the autosize method in order to have them take the size of the longest data value in each column.
// Forces the spreadsheet to take the size of the longest value             
for ($col = 'A'; $col != 'F'; $col++) { //Runs through all cells between A and E and sets to autosize
    $objPHPExcel->getActiveSheet()->getColumnDimension($col)->setAutoSize(true);
}
Next, I am adding an image, but it stretches across 4 columns, which it shouldn't.
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Paid');
$objDrawing->setDescription('Paid');
$objDrawing->setPath('../../Examples/images/paid.png');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
This is what is occuring (It should only be as wide as the first column):
enter image description here

I have removed the autosize method and it takes the correct size, so I know it is affecting the size of the image.

How can I remove the autosize from the image but leave it applied for the columns of data?
Coordinator
Aug 3, 2013 at 10:04 AM
Try adding
$objDrawing->setResizeProportional(false);