关于保存excel文件的问题

bergkamps 2004-11-04 09:56:25
查询出的结果是使用excel的形式显示在也面上的
如何通过页面的一个保存按钮将该页的excel文件保存到客户端
...全文
130 2 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
bergkamps 2004-11-04
  • 打赏
  • 举报
回复
to:jxflll(峰)
其实我要的就是一个模拟ie的保存按钮的功能
由于我的这个程序运行起来比较慢
你的方法在这里不太合适
jxflll 2004-11-04
  • 打赏
  • 举报
回复
你可以再执行一次SQL语句,把结果直接写到excel表中。下面是我以前做过的一个例子。可以往excel表中写内容。你可以参考一下。
##################################################
<?php
$mylink=mysql_connect("192.168.0.19","root","root");
mysql_select_db("IVR_RcdDB",$mylink);
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Content-type:application/vnd.ms-excel");
Header("Content-Disposition:attachment;filename=export_excel.xls");
$tx='省呼叫次数昨天、今天对比';
echo $tx."\n\n";
########################################
$p=0;
//>>>>>>>>>>>>>输出业务名
$sql_output="select count(*) as a,SpNum from IVR_TrffForm where 1=1 and StartTime>='".$date_from."' and StartTime<='".$date_to."' and SpNum<>'' group by SpNum order by a desc";
$result_output=mysql_query($sql_output,$mylink);
if(mysql_num_rows($result_output)>0){
echo "\t";
while($array_yh=mysql_fetch_array($result_output)){
echo $array_yh['SpNum'].'业务'."\t\t";
$p=$p+1;
}
}
echo "\n";
echo "\t";
?>
相关推荐
发帖
JavaScript

8.7w+

社区成员

Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
帖子事件
创建了帖子
2004-11-04 09:56
社区公告
暂无公告