一個利用header()函數來實例簡單的文件下載,我們簡單的講解了excel的操作教程,有需要的朋友可以參考一下。 代碼如下 復制代碼
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=test_data.xls");
實例
$filename = "20090210.xls";
$file = fopen(PUBLIC_EXPORT_DIR.$filename,"r"); // 打開文件
Header("Content-type:application/force-download");
Header("Accept-Ranges:bytes");
header("Content-Type: application/msexcel");
Header("Accept-Length:".filesize(PUBLIC_EXPORT_DIR.$filename));
Header("Content-Disposition:attachment;filename=".$filename);
echo fread($file,filesize(PUBLIC_EXPORT_DIR.$filename));
fclose($file);