我要将客户名单导到excel,用php怎么做? 在你要导出的页面前面加上下面的代码就可以了<?header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename=user.xls");?> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用php生成excel文件<?header("Content-type:application/vnd.ms-excel");header("Content-Disposition:filename=test.xls");echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";?> 在php环境运行上面的代码,大家就可以看到浏览器询问用户是否下载excel文档,点击保存,硬盘上就多了一个excel的文件,使用excel打开就会看到最终的结果,怎么样不错吧。 其实在做真正的应用的时候,大家可以将数据从数据库中取出,然后按照每一列数据结束后加\t,每一行数据结束后加\n的方法echo出来,在php的开头用header("Content-type:application/vnd.ms-excel");表示输出的是excel文件,用header("Content-Disposition:filename=test.xls");表示输出的文件名为text.xls。这样就ok了。 我们更可以修改header让他输出更多格式的文件,这样php在处理各种类型文件方面就更加方便了. <?header("Content-type:application/vnd.ms-excel");header("Content-Disposition:filename=test.xls");echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";echo "test1\t";echo "test2\t\n";?>我把这段代码在服务器上测试,出现无法下载的错误。 用个表单,POST到这个页面呢 ? 安装了apache只能在360浏览器上测试有用 高分求助:web开发时遇到的字符编码问题 PHP如何去掉所调用中文字间的所有空格? php调试问题 在ubuntu下安装php版本问题 初识PHP,有些很基本的问题不太懂,希望各位大侠指教(散分^_^) 公司的短信平台出现问题,不知道从哪里下手,急!困惑! php通过apache产生的cookie值,c中怎么把它读取出来(在线等待) 请教各位大哥大姐!这里如何写进mssqlserver数据库的表中去??? php 的库文件 求一个查询语句 如何获取下拉列表的text文字而不是索引值?
<?
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
?>
在php环境运行上面的代码,大家就可以看到浏览器询问用户是否下载excel文档,点击保存,硬盘上就多了一个excel的文件,使用excel打开就会看到最终的结果,怎么样不错吧。
其实在做真正的应用的时候,大家可以将数据从数据库中取出,然后按照每一列数据结束后加\t,每一行数据结束后加\n的方法echo出来,在php的开头用header("Content-type:application/vnd.ms-excel");表示输出的是excel文件,用header("Content-Disposition:filename=test.xls");表示输出的文件名为text.xls。这样就ok了。
我们更可以修改header让他输出更多格式的文件,这样php在处理各种类型文件方面就更加方便了.
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
?>
我把这段代码在服务器上测试,出现无法下载的错误。