使用php导出xlsx文件

时间:2015-08-03 12:43:20

标签: php http-headers phpexcel xlsx

我需要在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

0 个答案:

没有答案