Search This Blog

2016/12/08

How to set PHPExcel header

Code:
//.xls file
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=download.xls");

//.xlsx file
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header("Content-Disposition: attachment; filename=download.xlsx");

//Same part:
header("Cache-Control: max-age=0");

// Sample
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-ravalidate, post-check=0, pre-check=0');
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header("Content-disposition: attachment; filename=sample.xls");

References:
https://support.microsoft.com/en-us/kb/936496

No comments :

Post a Comment