PHP輸出到WORD跟EXCEL 簡易做法
Temperature: 0 °C
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');