PHP導出word(純文字)

<?php
echo '
<html xmlns:o="urn:schemas-microsoft-com:office:office"  xmlns:w="urn:schemas-microsoft-com:office:word"  xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<xml><w:WordDocument><w:View>Print</w:View></xml>
<script src="includes/js/ztree/js/jquery-1.4.4.min.js" type="text/javascript"></script>
</head>
<body>
//這裏是你想輸出的內容,按HTML的格式就能夠了。
</body>
</html>
';

ob_start(); //打開緩衝區
header("Cache-Control: public");
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");

if (strpos($_SERVER["HTTP_USER_AGENT"],'MSIE'))
{
header('Content-Disposition: attachment; filename='.$row->name.$row->date.'.doc');
}
else if (strpos($_SERVER["HTTP_USER_AGENT"],'Firefox'))
{
Header('Content-Disposition: attachment; filename='.$row->name.$row->date.'.doc');
}
else
{
header('Content-Disposition: attachment; filename='.$row->name.$row->date.'.doc');
}
header("Pragma:no-cache");
header("Expires:0");
ob_end_flush();
?>javascript

這是網上找的代碼,改一改終於能夠用,雖然也不清楚具體是什麼原理,可是能解決問題就好了先。有空再理解一下代碼的含義吧~(雖然這麼說基本就不會看了)待續……php

相關文章
相關標籤/搜索