I use the following headers to output the excel sheet generated through PHPExcel:
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="01simple.xlsx"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
Instead of the tab text, it is sent to the browser:
PK &DG D X [Content_Types].xml MN 0 " %nY vAa (0 ؖg w{&i @ nbE { y d۸l
m X ( ) F ;@1_ c)j x/% E y
Can someone help me with the correct headers to download the excel file? Many thanks.
Change 1:
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="01simple.xlsx"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
Does not work
source
share