Home > php教程 > php手册 > PHP export styled Excel

PHP export styled Excel

WBOY
Release: 2016-09-02 08:42:20
Original
1157 people have browsed it

When exporting at work, I need to export a customized table or I feel that the exported Excel format is too ugly.
You need to set color, font size, bold, merge cells, etc.

效果图:

PHP export styled Excel

PHP代码:/**<br> *Export file<br> * @return string<br> ​*/<br> public function export()<br> {<br>     $file_name   = "成绩单-".date("Y-m-d H:i:s",time());<br>     $file_suffix = "xls";<br>     header("Content-Type: application/vnd.ms-excel");<br>     header("Content-Disposition: attachment; filename=$file_name.$file_suffix");<br>     //根据业务,自己进行模板赋值。<br>     $this->display();<br> }HTML代码:<html xmlns:o="urn:schemas-microsoft-com:office:office"<br /> xmlns:x="urn:schemas-microsoft-com:office:excel"<br /> xmlns="http://www.w3.org/TR/REC-html40"><br> <br> <head><br> <meta http-equiv=Content-Type content="text/html; charset=utf-8"><br> <meta name=ProgId content=Excel.Sheet><br> <meta name=Generator content="Microsoft Excel 11"><br> </head><br> <br> <body><br> <table border=1 cellpadding=0 cellspacing=0 width="100%" ><br>      <tr><br>          <td colspan="5" align="center"><br>              <h2>成绩单</h2><br>          </td><br>      </tr><br>      <tr><br>          <td style='width:54pt' align="center">编号</td><br>          <td style='width:54pt' align="center">姓名</td><br>          <td style='width:54pt' align="center">语文</td><br>          <td style='width:54pt' align="center">数学</td><br>          <td style='width:54pt' align="center">英语</td><br>      </tr><br> <br>      <tr><br>         <td align="center">1</td><br>         <td style="background-color: #00CC00;" align="center">Jone</td><br>         <td style="background-color: #00adee;" align="center">90</td><br>         <td style="background-color: #00CC00;" align="center">85</td><br>         <td style="background-color: #00adee;" align="center">100</td><br>      </tr><br> <br>     <tr><br>         <td align="center">2</td><br>         <td style="background-color: #00CC00;" align="center">Tom</td><br>         <td style="background-color: #00adee;" align="center">99</td><br>         <td style="background-color: #00CC00;" align="center">85</td><br>         <td style="background-color: #00adee;" align="center">80</td><br>     </tr><br> <br> </table><br></body><br> </html>Thanks ~

Source: http://mp.weixin.qq.com/s?__biz=MjM5NDM4MDIwNw==&mid=2448834670&idx=1&sn=1cccfd60a7227972958d75f3d775c669#rd

For more [dry information sharing], please follow my personal subscription account.

PHP export styled Excel

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template