Write and Download

May 5, 2011 at 1:28 PM


I downloaded the library and working great. 

There is an excel template file I can write into it and save it correctly with utf-8 info; BUT instead of SAVE and I would like to download the file.



Write and Save to excel file is working on LOCALHOST of my computer; BUT when I migrate on the live server it is not working.



May 5, 2011 at 2:04 PM

The tests folder in the PHPExcel package has a number of download examples.

How exactly is your live one not working?

May 8, 2011 at 6:11 AM

I have checked the tests folder examples and were great.


$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

 $objWriter->save(str_replace('.php', '.xls', __FILE__));

header("Location:holders.php?xls"); die();


The above snippet works great on localhost, BUT when I am migrate my code on the live server I don't want saving on the root directory also the code does work.


When Using the following snippet 

// Redirect output to a client’s web browser (Excel5)

header('Content-Type: application/vnd.ms-excel');

header('Content-Disposition: attachment;filename="01simple.xls"');

header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');


On my localhost this brings the download windows but after the download is finished when I open the file everything missed up wrong characters ....


If you please let me know after writing to the template how it is possible to force it for download.


Thank you