Images not appearing using Excel5?

Topics: Developer Forum
Jul 21, 2008 at 9:23 AM

I am using PHPExcel to create on-the-fly reports, and at the top of the reports I am trying to include a logo. This all works fine when using Excel2007, but when I try using Excel5 instead even though there is no error, it simply refuses to put the image on the excel document.

Unfortunately because the people who will use this don't have the latest version of Excel, I have to use the Excel5 class...

I've stripped out all the other code, and this is the part of my code that doesn't seem to work:


  /** PHPExcel */
  include 'PHPExcel.php';

  /** PHPExcel_Writer_Excel5 */
  include 'PHPExcel/Writer/Excel5.php';

  // Create new PHPExcel object
  $objPHPExcel = new PHPExcel();

  // Send the headers to allow this document to be sent to the browser rather than saving it to disk
  header("Pragma: public");
  header("Expires: 0");
  header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  header("Content-Type: application/force-download");
  header("Content-Type: application/octet-stream");
  header("Content-Type: application/download");;
  header("Content-Disposition: attachment;filename=test.xls");
  header("Content-Transfer-Encoding: binary ");

  $objDrawing = new PHPExcel_Worksheet_Drawing();

  // Set active sheet index to the first sheet, so Excel opens this as the first sheet
  // Save Excel 2005 file
  $objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
  // Send the document to the browser

If I change the class I'm using to the Excel2007 one everything works fine. Originally I had used a jpeg but this was bringing up an error - I take it Excel5 doesn't support image types other than bipmaps so I converted the image to that. But it still doesn't work!

The excel document opens fine, and when I have other code in there the data is printed fine, it seems to just be the image part that isn't working.

Can someone please help me and let me know if it is something I am doing wrong?

Jul 22, 2008 at 4:20 PM
Can you try running 05featuredemo.php and 14excel5.php tests? 14excel5.php should also output an image.
Feb 17, 2009 at 6:14 AM
I used phpExcel and do well for generate image in Excel 2007 but still did not in Excel5 format. I try to run 05featuredemo.php and 14excel5.php and the file *.xls can't output image. What must i do ? Thx.
Feb 17, 2009 at 6:20 AM
What application are you using to view the xls file in? If you're using, then PHPExcel 1.6.5 will not suffice. Please upgrade your PHPExcel to latest source: