資料載入中

胡言亂語

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

發表留言

作者簡介

離不開電腦的宅男


推薦閱讀

作者其他相關類別故事

PHP清空陣列函數

PHP清空陣列函數

Mark Chang 8 年又 107 天 2.1K

將整個陣列清空,但之後如果再加入元素,其 index 是往上累加的,而非從 0 開始。 使用 un...

PHP Caching Headers

PHP Caching He…

Mark Chang 8 年又 38 天 2K

最近測試平台系統執行速度,老實說測試的有點無力~ 總覺得能做的可以做的都做了,但速度就是快不了~...

PHP查詢陣列中是否存在特定字串in_array 函數

PHP查詢陣列中是否存在特定…

Mark Chang 4 年又 144 天 1.9K

使用函數inarray() ,適用版本(PHP 4, PHP 5, PHP 7, PHP 8) 使...