thinkphp怎么导出excel

发布网友

我来回答

1个回答

热心网友

先建一个excel文件,把表头格式调整好,然后另存为html格式,用浏览器打开,查看源代码,复制源代码到后台,然后循环拼tr部分的字符串,然后输出字符串

//$filename是文件名,自定义
header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename={$filename}.xls");
$str=' <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="
!--[if gte mso 9]> <xml> <o:DocumentProperties> <o:Author>Administrator</o:Author> <o:Created>2015-06-19T11:43:47</o:Created> <o:LastSaved>2015-06-19T13:11:58</o:LastSaved> </o:DocumentProperties> <o:CustomDocumentProperties> <o:KSOProctBuildVer dt:dt="string">2052-9.1.0.5108</o:KSOProctBuildVer> </o:CustomDocumentProperties> </xml> <![endif]--> <style><!-- @page {margin:0.98in 0.75in 0.98in 0.75in; mso-header-margin:0.51in; mso-footer-margin:0.51in;}tr {mso-h这样就可以了,你试试吧,希望能帮你解决麻烦,好了我去后盾人补充知识储备了ヾ( ̄▽ ̄)Bye~Bye~

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com