資料載入中

胡言亂語

PHP輸出到WORD跟EXCEL 簡易做法


PHP輸出到WORD跟EXCEL 簡易做法
WORD:
$filename="test.doc";
header('Pragma: public');
header("Content-disposition: attachment; filename=".$filename.";charset=utf-8");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header ("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: utf-8');
header("Content-Type: application/vnd.ms-word");

EXCEL:
$filename="test.xls";
header('Pragma: public');
header("Content-disposition: attachment; filename=".$filename.";charset=utf-8");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header ("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: utf-8');
header('Content-Type: application/vnd.ms-excel');

 

https://innstory.com/story-PHP輸出到WORD跟EXCEL簡易做法-1533

上一篇
 解決svchostexe消耗記憶體問題

下一篇
修改php設定 
  • 2,345
  • 0
  • 0

發表留言

作者簡介

離不開電腦的宅男


推薦閱讀

作者其他相關類別故事

Android Fragment及Activity 中使用sharedpreferences

Android Fragme…

Mark Chang 7 年又 27 天 2.3K

在Android下想要儲存執行資料的方式有好幾種,例如存在手機空間或者是資料庫空間。 這裡紀錄一下使...

php定時執行任務ignore_user_abort 函式

php定時執行任務ignor…

Mark Chang 6 年又 84 天 3K

ignoreuserabort() 函式 最近剛好有一個專案需要定時執行任務功能,原本一開始想到的是...

Linux vi修改文件時遇到:E212無法打開文件進行寫入

Linux vi修改文件時遇…

Mark Chang 5 年又 147 天 2.1K

執行修改 使用wq(儲存後離開)或者是wq!(唯讀檔案強制儲存後離開)指令 卻一直出現提示E ca...