I am using PHPExcel to export data from my PHP page to Excel. I am using Excel5.
I want the excel file to be be saved a particular folder that is specified in the code
OR better still,
I want Excel to open with the data written in it so that user can save it wherever he wants. What should I do.
Please guide me
Pre
I solved this problem doing this:
$objWriter->save(str_replace(__FILE__,'/path/to/save/filename.extension',__FILE__));
In my case, it worked!
This will ask the user to save / open the file:
$excel = new PHPExcel();
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="your_name.xls"');
header('Cache-Control: max-age=0');
// ...
$writer = PHPExcel_IOFactory::createWriter($excel, 'Excel5);
$writer->save('php://output');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With