-
-
Save vielhuber/c7a9482c4acaaa3896a9 to your computer and use it in GitHub Desktop.
<?php | |
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); | |
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); | |
header('Content-Disposition: attachment;filename="' . $filename . '.xlsx"'); | |
$objWriter->save('php://output'); | |
die(); |
I have problem same.
using PHPExcel in ajax
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $filename . '.xlsx"');
$objWriter->save('php://output');
not output file excel??
but using save in local -> output file excel
$objWriter->save(' . $filename . '.xlsx);
help me. solusion give me
Can you please provide a fully working example (including data)?
Also please use PhpSpreadsheet instead of PhpExcel.
If you want to display the content on the browser (Note, it seems to be showing the first sheet only)
$writer = IOFactory::createWriter($spreadsheet, 'Html');
$message = $writer->save('php://output');
In using this method, I am having issues. I am trying to send the information directly as a download to the browser, using this code:
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); header("Content-Disposition: attachment; filename=\"".$filename."\""); $writer->save('php://output');
It writes the file to the browser, except it's filled with special encoded characters, and not the actual file when opened. If I don't push to the browser and instead just save the file to a .xlsx in my temp directory, I can open the document correctly.
I even tried pointing to the file using readfile('/tmp/filename.xlsx'); and it opens with special characters and no cells or data.
Can you please provide a working example to reproduce this issue? I will then have a look at it.
@justinfurnas your issue belongs more on a support forum than here. Having said that, check that your filename is correctly names with an extension xlsx. Then the browser will know what to do with it.
Yes, that's correct. However, you can achieve the same with the successor PhpSpreadsheet: