首先,在index.php文件中,创建链接:<a href="test1.php">导出excel</a>。
test1.php文件内容:
 
以上就是php导出excel的实例代码,大家可以测试下。
另外,提供一个导出word文档的例子。
代码:
 
<?php 
/**
* php导出word文件
* site: www.jb200.com
*/
header("Content-Type:   application/msword");        
header("Content-Disposition:   attachment;   filename=doc.doc");        
header("Pragma:   no-cache");        
header("Expires:   0");       
$output    =   '<table border="1" cellspacing="2" cellpadding="2" width="90%" align="center">';        
$output   .=   '<tr bgcolor="#cccccc"><td   align="center">图片</td></tr>';        
$output   .=   '<tr bgcolor="#f6f7fa"><td><span style="color:#FF0000;"><strong>下面是一张图片</strong></span></td></tr>';        
$output   .=   '<tr><td align="center"><img src=";        
$output   .=   '</table>';
echo   $output;        
?>
附,PHP生成Excel文件的最简方法,小例子,学习用。