求教 :如何实现将查询出的数据导出到excel 我想实现这样的功能,从数据库查询出的数据展现在一个新的页面上,在页面上显示为一个有若干行的表格,在表格下方设置一个按钮(按钮与查询出的数据在一个页面上),点击按钮,弹出提示下载框,将查询出的数据保存到excel,这个如何实现,望高手不吝赐教,主要是这个按钮和按钮触发的东西怎么做。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?phpif ($_REQUEST['opt'] == "export"){ //导出的操作 echo "exporting...";}?><script>function exportcsv(){ if(confirm('确认导出吗?')){ f_export.opt.value='export'; } else{ f_export.opt.value='search'; } f_export.submit();}</script><form name="f_export" method="post"><table border="1"><tr><td>id</td><td>name</td><td>date</td></tr><?phpfor ($i=0; $i<10; $i++){?><tr><td><?php echo $i;?></td><td>aa</td><td>2009-09-09</td></tr><?php}?><tr><input type="button" onclick="exportcsv();" value="export"></tr></table><input type="hidden" name="opt" value=""></form> http://www.rsywx.net/misc/lakers.php先看看是不是你想要的…… 做过相关开发,并不复杂,你可以直接向浏览器输出header信息:$file_type = "vnd.ms-excel";$file_ending = "xls";header("Content-Type: application/$file_type;charset=utf-8");header("Content-Disposition: attachment; filename=mydowns.$file_ending");header("Pragma: no-cache");header("Expires: 0");echo 'test test2 test3';//用tab键分开好了也可以用一些较成熟的类,下面这个是我用过的,还可以:http://search.cpan.org/dist/Spreadsheet-WriteExcel/ netbeans PHP 一直运行不了 一个读取网页固定点的数据的问题 请求http(post方式)问题 求助:php中的sql语句无法识别某些字符 新闻录入 为什么我的网页图片不能完全显示??? nginx rewrite 一个地址能写两个规则么 请教个APACHE PHP环境有关的问题 取得一个字串首字符最高效的方法是什么? 为什么我的php+iis8.5二级域名不能共享主域名的session 对聊天室程序的一点疑问 rmb求PHP小程序,就今天要~~急
if ($_REQUEST['opt'] == "export")
{
//导出的操作
echo "exporting...";
}
?><script>
function exportcsv()
{
if(confirm('确认导出吗?')){
f_export.opt.value='export';
}
else{
f_export.opt.value='search';
}
f_export.submit();
}
</script>
<form name="f_export" method="post">
<table border="1">
<tr>
<td>id</td>
<td>name</td>
<td>date</td>
</tr>
<?php
for ($i=0; $i<10; $i++)
{
?><tr><td><?php echo $i;?></td><td>aa</td><td>2009-09-09</td></tr>
<?php
}
?><tr><input type="button" onclick="exportcsv();" value="export"></tr>
</table>
<input type="hidden" name="opt" value="">
</form>
$file_ending = "xls";
header("Content-Type: application/$file_type;charset=utf-8");
header("Content-Disposition: attachment; filename=mydowns.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
echo 'test test2 test3';//用tab键分开好了
也可以用一些较成熟的类,下面这个是我用过的,还可以:http://search.cpan.org/dist/Spreadsheet-WriteExcel/