<html xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
word 中要显示的内容, 由于word支持html格式, 所以中间这一部分使用html文档就可以.
</html>
如果做文件下载:
<?php
header("Content-type:application/vnd.ms-word");
header("Content-Disposition:filename=download.xls");
echo '<html xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
';
echo "输出你的内容就可以文件下载了":
echo '</html>';
?>
以上只是简单的doc文件的存储,excl 其实用table 导出excel就事半功倍.
可以把客户端的要导出的table的html传送到服务器然后使用
html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="expires" content="Mon, 06 Jan 1999 00:00:01 GMT">
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name></x:Name>
<x:WorksheetOptions>
<x:DisplayGridlines/>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml><![endif]-->
</head>
<table>
<tr>
<td>测试,使用table可以导出复杂的 excel表格</td>
</tr>
</table>
</html>
把上面代码保存为xls格式即可