title: PHPExcel: Set row height in pixels
body: <p>I'm using PHPExcel to write a set of images to an Excel file using PHP.
  Inserting the images doesn't seem to be a problem, however I'm having some difficulties setting the appropriate row height to match the image height.</p>
  
  <p>I managed to use pixelsToCellDimension to calculate the correct column width, but this doesn't seem to be appropriate for calculating row height.
  After checking out the rest of the functions in the PHPExcel_Shared_Drawing class and Googling around, I'm left dumbfounded as to how to do this.</p>
  
  <p>My code so far:</p>
  
  <pre><code>// Create new PHPExcel object
  $objPHPExcel = new PHPExcel();
  
  // Set document properties
  $objPHPExcel-&gt;getProperties()-&gt;setCreator("creator")
      -&gt;setLastModifiedBy("modifiedby")
      -&gt;setTitle("Title")
      -&gt;setSubject("Subject")
      -&gt;setDescription("Description")
      -&gt;setKeywords("keyword1 keyword2")
      -&gt;setCategory("category");
  
  // Get default font
  $defaultFont = $objPHPExcel-&gt;getDefaultStyle()-&gt;getFont();
  </code></pre>
  
  <p>[some code to generate my images and add their paths to an array]</p>
  
  <pre><code>foreach( $filePaths as $i =&gt; $filePath ) {
      $objDrawing = new PHPExcel_Worksheet_Drawing();
      $objDrawing-&gt;setWorkSheet( $objPHPExcel-&gt;getActiveSheet() );
      $objDrawing-&gt;setName("name");
      $objDrawing-&gt;setDescription("Description");
      $objDrawing-&gt;setPath( $filePath );
  
      $size = getimagesize($filePath);
      $columnWidth = PHPExcel_Shared_Drawing::pixelsToCellDimension($size[0], $defaultFont);
      $rowHeight = PHPExcel_Shared_Drawing::pixelsToCellDimension($size[1], $defaultFont);
  
      $objDrawing-&gt;setCoordinates('A' . ($i+1) );
      $objDrawing-&gt;setOffsetX(0);
      $objDrawing-&gt;setOffsetY(0);
  
      // set row/column (cell) sizes to match image size
      $objPHPExcel-&gt;getActiveSheet()
         -&gt;getColumnDimension('A')
         -&gt;setWidth( $columnWidth );
      $objPHPExcel-&gt;getActiveSheet()
         -&gt;getRowDimension( $i+1 )
         -&gt;setRowHeight( $rowHeight );
  }
  
  // Rename worksheet
  $objPHPExcel-&gt;getActiveSheet()-&gt;setTitle('Worksheet 1');
  
  // Set active sheet index to the first sheet, so Excel opens this as the first sheet
  $objPHPExcel-&gt;setActiveSheetIndex(0);
  
  // Redirect output to a client’s web browser (Excel5)
  header('Content-Type: application/vnd.ms-excel');
  header('Content-Disposition: attachment;filename="myMCS Scancode Export.xls"');
  header('Cache-Control: max-age=0');
  
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
  $objWriter-&gt;save('php://output');
  exit;
  </code></pre>