How can manipulate images?

Topics: Developer Forum, Project Management Forum, User Forum
Aug 6, 2009 at 7:34 AM

 i tried load excel to phpexcel

but The image will be reduced by increased cell... (save to file)

i want to know how can control images in phpexcel...


Aug 6, 2009 at 7:38 AM

Is this happening with Excel2007 or Excel5 writer. Do you have some sample code? Also, is it happening with latest source code?

Aug 6, 2009 at 11:26 AM
Thanks for koyama.
this happen is Excel5 writer
$objPHPExcel = PHPExcel_IOFactory::load("new_org.xls");   // excel load
$objPHPExcel->getActiveSheet()->getRowDimension('7')->setRowHeight(100);  // row height rise
$objPHPExcel->getActiveSheet()->setCellValue('D7',mb_convert_encoding($strHead,'utf-8','euc-kr'));    // $strHead is string
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');  // writer
$objWriter->save('omgmyexcel.xls'); // save
this source...
i will send you excel file
Aug 6, 2009 at 11:52 AM
Edited Aug 7, 2009 at 5:34 AM


Aug 6, 2009 at 11:47 PM

This is strange. Can you send me the Excel file (new_org.xls) so I can test?

Please send to this email address: erik at phpexcel dot net

Aug 7, 2009 at 5:49 AM
Email sent now. get mail
thank you.
Aug 7, 2009 at 10:43 PM

[File received]

I notice the squeezed image. The error happens with Excel5 writer when the image overlaps rows with AutoFit height (usually containing some wrapped text).

PHPExcel does unfortunately not have (true) support for "AutoFit Row Height". For example, sometimes you want a paragraph of text in a cell, and the height of the row should adapt. In this case you want "AutoFit Row Height" in Excel.

Technically, PHPExcel does not support this because it is not able to calculate AutoFit row heights. In some cases this is a problem. For example there is a problem calculating (2-anchor) image position properties in Excel5 writer when the image overlaps an AutoFit row height.


There is currently no 100% satisfactory workaround. Some possibilities for you:

  1. Think about if it is possible to switch to Excel2007 writer? This writer does not have the problem.
  2. Set an explicit row height (to some suitable value) for the rows which the image overlaps. This will always fix the problem with the squeezed image. This is not autoFit, but sometimes it may be ok anyway.