資料載入中

胡言亂語

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設定 

發表留言

作者簡介

離不開電腦的宅男


推薦閱讀

作者其他相關類別故事

PHPimplode 將陣列轉成字串

PHPimplode 將陣列…

Mark Chang 8 年又 109 天 2.4K

使用implode將陣列轉換成字串; 輸出結果: a,b,c,d,e

使用PHP取得目前網址方式

使用PHP取得目前網址方式

Mark Chang 8 年又 106 天 2.3K

使用PHP取得網址相關的方式有下列幾種: 以下修改,是為了資安。 老了,純粹只是記錄~

.htaccess與RewriteEngine一起使用時500內部服務器錯誤

.htaccess與Rewr…

Mark Chang 5 年又 269 天 1.6K

在某些情況下,可能未加載apache中的modrewrite模塊。 這時只需要執行以下指令就可以獲...