Apr 1, 2015 at 11:21 AM
Edited Apr 1, 2015 at 11:22 AM
I had an issue trying to generate a downloadable Excel2007 formatted file using PHPExcel 1.8.0.
The download was offered correctly when I developed it on my home WAMP server, but when I transfered my project to my live (hosted) website, I only got an empty page and no download.
The final part of the script contains:
$filename = "Myfile.xlsx";
header("Content-disposition: attachment; filename=\"".$filename."\"");
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
By investigating the issue I found out the "save('php://output');" part didn't return a correct temp dir for the temporary file to be created. In my situation it doesn't have anything to do with "write permissions", but with sys_get_temp_dir()
not reurning the correct directory for temporary files.
I have changed line 197 of "PHPEcel/Writer/Excel2007" from:
$pFilename = @tempnam(PHPExcel_Shared_File::sys_get_temp_dir(), 'phpxltmp');
My issue is resolved now and maybe this helps others too! :)