PHP输出CSV和EXCEL两种简单的方法

1、定义 header()头部输出格式 

header("Content-type:application/vnd.ms-excel");

header("Content-Disposition:filename=php100.xls");

 2、输出编码和支持的格式

 (1)支持普通格式的CSV 文本规范,以空格和换行来识别

 常用: \t \n 填充空白和换行

A1\tB1\tC1\n

A2\tB2\tC2\n

A3\tB3\tC3\n 

 (2)支持简单的HTML代码和表格规范

 常用:table 规范 ,表格合并规范,Font标签规范

 <table>

    <tr>
      <td colspan="3"><font color=red>PHP100财务统计</font></td>
    </tr>
    <tr>
      <td>t10</td><td>t11</td><td>t12</td>
    </tr>
    <tr>
      <td>t20</td><td>t21</td><td>t22</td>
    </tr>
  </table>
原文地址:https://www.cnblogs.com/lihong/p/1959412.html