动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   PHP → 阅读文章

 生成Excel文件范例(1):服务端

作者来源: 
阅读 1576 人次 , 2006-3-29 4:08:00 


<?php
ob_start();

?>
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/tr/rec-html40">

<head>
<meta http-equiv=content-type content="text/html; charset=gb2312">
<meta name=progid content=excel.sheet>
<meta name=generator content="microsoft excel 10">
<link rel=file-list href="page.files/filelist.xml">
<style id="book1_10519_styles">
<!--table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
.font510519
{color:windowtext;
font-size:9.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;}
.xl1510519
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:general;
text-align:general;
vertical-align:middle;
mso-background-source:auto;
mso-pattern:auto;
white-space:nowrap;}
.xl2210519
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:general;
text-align:general;
vertical-align:middle;
border:.5pt solid windowtext;
background:silver;
mso-pattern:auto none;
white-space:nowrap;}
.xl2310519
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:general;
text-align:general;
vertical-align:middle;
border:.5pt solid windowtext;
mso-background-source:auto;
mso-pattern:auto;
white-space:nowrap;}
ruby
{ruby-align:left;}
rt
{color:windowtext;
font-size:9.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-char-type:none;}
-->
</style>
</head>

<body>
<!--[if !excel]>  <![endif]-->
<!--下列信息由 microsoft excel 的“发布为 web 页”向导生成。-->
<!--如果同一条目从 excel 中重新发布,则所有位于 div 标记之间的信息均将被替换。-->
<!----------------------------->
<!--“从 excel 发布 web 页”向导开始-->
<!----------------------------->

<div id="book1_10519" align=center x:publishsource="excel">
<?php
if(false==isset($_post["data"]))
{
echo "没有要显示的数据" ;
exit;
}
?>
<table x:str border=0 cellpadding=0 cellspacing=0 width=519 style='border-collapse:
collapse;table-layout:fixed;width:389pt'>
<col width=72 span=2 style='width:54pt'>
<col width=163 style='mso-width-source:userset;mso-width-alt:5216;width:122pt'>
<col width=87 style='mso-width-source:userset;mso-width-alt:2784;width:65pt'>
<col width=125 style='mso-width-source:userset;mso-width-alt:4000;width:94pt'>
<tr height=19 style='height:14.25pt'>
<td height=19 class=xl1510519 width=72 style='height:14.25pt;width:54pt'></td>
<td class=xl1510519 width=72 style='width:54pt'></td>
<td class=xl1510519 width=163 style='width:122pt'></td>
<td class=xl1510519 width=87 style='width:65pt'></td>
<td class=xl1510519 width=125 style='width:94pt'></td>
</tr>
<tr height=19 style='height:14.25pt'>
<td height=19 class=xl1510519 style='height:14.25pt'></td>
<td class=xl2210519>名称</td>
<td class=xl2210519 style='border-left:none'>地址</td>
<td class=xl2210519 style='border-left:none'>qq号</td>
<td class=xl2210519 style='border-left:none'>电子邮件</td>
</tr>
<?php

foreach($_post["data"] as $val)
{
extract($val) ;
?>

<tr height=19 style='height:14.25pt'>
<td height=19 class=xl1510519 style='height:14.25pt'></td>
<td class=xl2310519 style='border-top:none'><?php echo $username ; ?></td>
<td class=xl2310519 style='border-top:none;border-left:none'><?php echo $add ; ?></td>
<td class=xl2310519 style='border-top:none;border-left:none'><?php echo $qq ; ?> </td>
<td class=xl2310519 style='border-top:none;border-left:none'><?php echo $email ; ?></td>
</tr>
<?php
}
?>

<![if supportmisalignedcolumns]>
<tr height=0 style='display:none'>
<td width=72 style='width:54pt'></td>
<td width=72 style='width:54pt'></td>
<td width=163 style='width:122pt'></td>
<td width=87 style='width:65pt'></td>
<td width=125 style='width:94pt'></td>
</tr>
<![endif]>
</table>

</div>


<!----------------------------->
<!--“从 excel 发布 web 页”向导结束-->
<!----------------------------->
</body>

</html>
<?php
$outstr=ob_get_contents();
ob_end_clean();
 
header("content-type: application/octet-stream");
header("accept-ranges: bytes");
header("accept-length: ".strlen($outstr));
header("content-disposition: attachment; filename=test.xls");
// 输出文件内容
echo $outstr ;
?> 

 本文TagsExcel  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:生成Excel文件范例(1):客户端
· 下一篇:PHP3/4.1 register_global=on转向PHP4.2/3 过度方法
· 最简单的文本计数器
· PHP如何读取COOKIES
· 这是一个记录用户踪迹的片段
· 生成Excel文件范例(1):服务端
· 用PHP发送MIME邮件(三)


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077