I need to download a file in XLS & XLSX format, I tried Many Way but it is not working.
My download code is as follows:
$file = "Reports.xlsx";
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
Both i Tried :
header('Content-type: application/octet-stream'); - not working
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); - not working
For Xls:
header("Content-Type: application/vnd.ms-excel; charset=UTF-8;"); - Working for Xls