我需要在XLS&amp ;;中下载文件XLSX格式,我试过很多方法,但它没有用。
我的下载代码如下:
$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);
我都试过:
header('Content-type: application/octet-stream'); - not working
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); - not working
对于Xls:
header("Content-Type: application/vnd.ms-excel; charset=UTF-8;"); - Working for Xls