I'm trying to use the .xlsx template, which already has headers and footers, upper and lower.

I upload a file, then immediately issue a new one:

/* путь к файлу верный */ $pExcel = PHPExcel_IOFactory::load($path); $objWriter = new PHPExcel_Writer_Excel5($pExcel); header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="myxls.xls"'); header('Cache-Control: max-age=0'); $objWriter->save('php://output'); 

Footer text is displayed, but there is no image.

If you put the output in the code and see what is shown in the images, then that's right.

Code:

 var_dump($aSheet->getHeaderFooter()->getImages()); 

Conclusion:

 array (size=1) 'LH' => object(PHPExcel_Worksheet_HeaderFooterDrawing)[1057] private '_path' => string 'zip://D:\JENTEK\mebs\trunk\application/../www/files/load.xlsx#xl/media/image1.png' (length=81) protected '_name' => string 'mebs_logo_excel' (length=15) protected '_offsetX' => string '0' (length=1) protected '_offsetY' => string '0' (length=1) protected '_width' => int 112 protected '_height' => int 145 protected '_resizeProportional' => boolean true private '_imageIndex' (PHPExcel_Worksheet_BaseDrawing) => int 0 protected '_description' => null protected '_worksheet' => null protected '_coordinates' => null protected '_rotation' => null protected '_shadow' => null private '_path' (PHPExcel_Worksheet_Drawing) => null 

However, this image in the generated file is not. Tell me, please, why so?

    1 answer 1

    In general, I found how to fix this problem. Maybe someone will be useful.

    The problem of the appearance of the image in the header and footer was that I used this class - PHPExcel_Writer_Excel5 (to create an Excel file), but loaded it from the load.xlsx file (a newer version of Excel).

    It turned out that I downloaded the Excel file for the years 2007-2010, and generated the file for the years 97-2003.

    Just in case, updated the phpExcel library from the official. site and generated a file through the class PHPExcel_Writer_Excel2007 ().

    It worked. Footer images are displayed.