PHP读取Excel 之 Spreadsheet_Excel_Reader和Writer

论坛 期权论坛     
选择匿名的用户   2021-5-30 02:05   355   0
<span style="font-family:Verdana,Helvetica,Arial,sans-serif; font-size:14px; line-height:24px; text-align:left">之前看到过好多关于PHP导出Excel的文章,自己也通过不少方法实现过,例如,echo一个Table,然后将header修改为Excel即可。</span>
<br style="word-wrap:break-word; line-height:24px; font-family:Verdana,Helvetica,Arial,sans-serif; font-size:14px; text-align:left">
<br style="word-wrap:break-word; line-height:24px; font-family:Verdana,Helvetica,Arial,sans-serif; font-size:14px; text-align:left">
<span style="font-family:Verdana,Helvetica,Arial,sans-serif; font-size:14px; line-height:24px; text-align:left">其实在众多方法中感觉Pear中的Spreadsheet_Excel_Writer很是好用。</span>
<br style="word-wrap:break-word; line-height:24px; font-family:Verdana,Helvetica,Arial,sans-serif; font-size:14px; text-align:left">
<br style="word-wrap:break-word; line-height:24px; font-family:Verdana,Helvetica,Arial,sans-serif; font-size:14px; text-align:left">
<span style="font-family:Verdana,Helvetica,Arial,sans-serif; font-size:14px; line-height:24px; text-align:left">关于Spreadsheet_Excel_Writer的</span>
<span class="t_tag" style="word-wrap:break-word; line-height:24px; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(255,0,0); white-space:nowrap; font-family:Verdana,Helvetica,Arial,sans-serif; font-size:14px; text-align:left">安装</span>
<span style="font-family:Verdana,Helvetica,Arial,sans-serif; font-size:14px; line-height:24px; text-align:left">本文不予介绍,可通过Google找到答案:) 也可参考:</span>
<a href="http://pear.php.net/package/Spreadsheet_Excel_Writer/download" rel="noopener noreferrer" style="word-wrap:break-word; text-decoration:none; color:rgb(0,102,204); line-height:24px; font-family:Verdana,Helvetica,Arial,sans-serif; font-size:14px; text-align:left" target="_blank">http://pear.<span class="t_tag" style="word-wrap:break-word; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(255,0,0); white-space:nowrap">php</span>.net/package/Spreadsheet_Excel_Writer/download</a>
<div class="blockcode" style="word-wrap:break-word; line-height:24px; margin:10px 0px; padding:10px 0px 5px 10px; width:700px; border:1px solid rgb(204,204,204); background-color:rgb(247,247,247); overflow:hidden; font-family:Verdana,Helvetica,Arial,sans-serif; font-size:14px; text-align:left">
<div id="code37936_-1" style="word-wrap:break-word">
  <ol style="word-wrap:break-word; margin:0px 0px 0px 10px; padding:0px"><li style="word-wrap:break-word; margin:0px 0px 0px 2em; padding:0px 0px 0px 10px; line-height:1.8em; list-style-type:decimal-leading-zero; font-family:Monaco,Consolas,&#39;Lucida Console&#39;,&#39;Courier New&#39;,serif; font-size:12px"> &lt;?php<br style="word-wrap:break-word"> </li><li style="word-wrap:break-word; margin:0px 0px 0px 2em; padding:0px 0px 0px 10px; line-height:1.8em; list-style-type:decimal-leading-zero; font-family:Monaco,Consolas,&#39;Lucida Console&#39;,&#39;Courier New&#39;,serif; font-size:12px"> //调用Writer.php<br style="word-wrap:break-word"> </li><li style="word-wrap:break-word; margin:0px 0px 0px 2em; padding:0px 0px 0px 10px; line-height:1.8em; list-style-type:decimal-leading-zero; font-family:Monaco,Consolas,&#39;Lucida Console&#39;,&#39;Courier New&#39;,serif; font-size:12px"> require_once &#39;Spreadsheet/Excel/Writer.php&#39;;<br style="word-wrap:break-word"> </li><li style="word-wrap:break-word; margin:0px 0px 0px 2em; padding:0px 0px 0px 10px; line-height:1.8em; list-style-type:decimal-leading-zero; font-family:Monaco,Consolas,&#39;Lucida Console&#39;,&#39;Courier New&#39;,serif; font-size:12px"> //创建Workbook<br style="word-wrap:break-word"> </li><li style="word-wrap:break-word; margin:0px 0px 0px 2em; padding:0px 0px 0px 10px; line-height:1.8em; list-style-type:decimal-leading-zero; font-family:Monaco,Consolas,&#39;Lucida Console&#39;,&#39;Courier New&#39;,serif; font-size:12px"> $workbook &#61; new Spreadsheet_Excel_Writer();<br style="word-wrap:break-word"> </li><li style="word-wrap:break-word; margin:0px 0px 0px 2em; padding:0px 0px 0px 10px; line-height:1.8em; list-style-type:decimal-leading-zero; font-family:Monaco,Consolas,&#39;Lucida Console&#39;,&#39;Courier New&#39;,serif; font-size:12px"> //定义导出Excel文件名<br style="word-wrap:break-word"> </li><li style="word-wrap:break-word; margin:0px 0px 0px 2em; padding:0px 0px 0px 10px; line-height:1.8em; list-style-type:decimal-leading-zero; font-family:Monaco,Consolas,&#39;Lucida Console&#39;,&#39;Courier New&#39;,serif; font-size:12px"> $workbook-&gt;send(&#39;test.xls&#39;);<br style="word-wrap:break-word"> </li><li style="word-wrap:break-word; margin:0px 0px 0px 2em; padding:0px 0px 0px 10px; line-height:1.8em; list-style-type:decimal-leading-zero; font-family:Monaco,Consolas,&#39;Lucida Console&#39;,&#39;Courier New&#39;,serif; font-size:12px"> //创建Worksheet<br style="word-wrap:break-word"> </li><li style="word-wrap:break-word; margin:0px 0px 0px 2em; padding:0px 0px 0px 10px; line-height:1.8em; list-style-type:decimal-leading-zero; font-family:Monaco,Consolas,&#39;Lucida Console&#39;,&#39;Courier New&#39;,serif; font-size:12px"> $worksheet &#61;&amp; $workbook-&gt;addWorksheet(&#39;My first worksheet&#39;);<br style="word-wrap:break-word"> </li><li style="word-wrap:break-word; margin:0px 0px 0px 2em; padding:0px 0px 0px 10px; line-height:1.8em; list-style-type:decimal-leading-zero; font-family:Monaco
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP