教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php输出excel文件的实例代码

php输出excel文件的实例代码

发布时间:2017-03-18   编辑:jiaochengji.com
本文介绍下,在php中输出excel文件的一例代码,很简单,主要是演示php将数据导出为excel文件的方法,有需要的朋友参考下。

本节内容:
php输出excel文件

例子:
 

复制代码 代码示例:

<?php
/**
* php导出excel文件
* by www.jbxue.com
*/
header('Content-Type: application/vnd.ms-excel; charset=GBK');
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: filename=test.xls');
?>
<html>
<style>
TD{
    font-size: 12px;
    vertical-align: middle;

}
strong{
    font-size: 14px;

}
</style>
<!--HTML中td元素的nowrap属性表示禁止单元格中的文字自动换行-->
<body>
<div><b>统考报名督促</b></div>
<table width="100%" border="1" align="center" cellspacing="1" cellpadding="1">
  <tr align="center">
    <td nowrap><b>序号</b></td>
    <td nowrap><b>学生姓名</b></td>
    <td nowrap><b>服务站</b></td>
    <td nowrap><b>学籍批次</b></td>
    <td nowrap><b>层次</b></td>
    <td nowrap><b>专业</b></td>
    <td nowrap><b>联系电话</b></td>
    <td nowrap><b>手机</b></td>
    <td nowrap><b>大学英语(B)</b></td>
    <td nowrap><b>计算机应用基础</b></td>
    <td nowrap><b>大学语文(A)</b></td>
    <td nowrap><b>大学语文(B)</b></td>
    <td nowrap><b>高等数学(B)</b></td>
  </tr>
  <tr align="center">
    <td nowrap>1</td>
    <td nowrap>qifei</td>
    <td nowrap>山东教学服务中心</td>
    <td nowrap>200509</td>
    <td nowrap>高起本</td>
    <td nowrap>计算机科技</td>
    <td nowrap>010-10101010</td>
    <td nowrap>13233333333</td>
    <td nowrap>通过</td>
    <td nowrap>未通过</td>
    <td nowrap>通过</td>
    <td nowrap>未通过</td>
    <td nowrap>免考</td>
  </tr>
  <tr align="center">
    <td nowrap>2</td>
    <td nowrap>qifei</td>
    <td nowrap>山东教学服务中心</td>
    <td nowrap>200509</td>
    <td nowrap>高起本</td>
    <td nowrap>计算机科技</td>
    <td nowrap>010-10101010</td>
    <td nowrap>13233333333</td>
    <td nowrap>通过</td>
    <td nowrap>未通过</td>
    <td nowrap>通过</td>
    <td nowrap>未通过</td>
    <td nowrap>免考</td>
  </tr>
</table>
<br>
<b>说明:</b><br>
1、china qifei<br>
2、Tianjin University<br>
</body>
</html>

附,其他格式文件:
 

header("Content-type:application/vnd.ms-word");  
header("Content-Disposition:filename=test.doc");
 
header("Content-type:application/vnd.ms-excel");  
header("Content-Disposition:filename=test.xls");
  
header("Content-type:application/vnd.ms-PowerPoint");  
header("Content-Disposition:filename=test.ppt");

您可能感兴趣的文章:
php导出word文档与excel表格文件
解决php下载excel无法打开的问题
PHP导出excel php使用phpexcel导出excel文件
php导入excel php使用phpexcel导入excel文件
php导出excel(不断刷新缓冲区)的实例代码
php更新修改excel中的内容例子
PHP导入与导出Excel文件的方法
php导出CSV文件的实现代码
php读取excel的实例代码
php导出数据为execel文件的实例分享

[关闭]
~ ~