php - PHPExcel: Set row height in pixels according to image -
is there way set row height according height of image?
example: put image (320x480 pixel) on d12 , want row #12 height fit image (480 pixel).
thanks!
this lot more complex might seem - have read of microsoft's own article on setting height/width
ms excel measures row height in points when specify height value in excel itself, point approximately 1/72 inch or 0.035 cm. phpexcel provide helper methods converting between points , pixels.
$pixels = 480; $points = phpexcel_shared_drawing::pixelstopoints($pixels);
and there corresponding phpexcel_shared_drawing::pointstopixels()
method
use helper calculate number of points pixel resolution of image, , set row height
internally though, excel officeopenxml format uses english metric units (or emus), 1 emu defined 1/360,000 of centimeter , there 914,400 emus per inch, , 12,700 emus per point.
this allows relatively straightforward conversions between different units, , again, phpexcel provides helper methods convert between pixels , emus.
$pixels = 480; $emu = phpexcel_shared_drawing::pixelstoemu($pixels);
and there corresponding phpexcel_shared_drawing::emutopixels()
method
if save file using excel2007 writer (which saves officeopenxml format) image dimensions converted emus, , when file subsequently reloaded there may slight discrepancy in conversion, allow slight margin in height set row allow this
Comments
Post a Comment