如何输出文件
现在需要将查询结果导出下载。function testExport()
{
header("content-type:application/vnd.ms-excel; charset=gbk");
header("content-disposition:attachment;filename=test.xls");
Header("Accept-Ranges: bytes");
echo "a\tb\r\n";
echo "1\t2";
}
这个是写在controllers,结果是以字符串的形式显示出来了。
好像header里的设置没有做用。
怎么回事? 响应头信息原始头信息
Date Thu, 20 Oct 2011 01:33:47 GMT
Server Apache/2.2.8 (Win32) PHP/5.2.6
X-Powered-By PHP/5.2.6
Keep-Alive timeout=5, max=100
Connection Keep-Alive
Transfer-Encoding chunked
Content-Type text/html
请求头信息原始头信息
Host localhost:8080
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:7.0) Gecko/20100101 Firefox/7.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language zh-cn,zh;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset GB2312,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Referer http://localhost:8080/main/left 检查一下你输出之前是不是有写过什么head类的东西。
我ci2.0弄的download和导出excel都没碰到这个问题。
页:
[1]