Content-Type: application/vnd.ms-excel">
来源:互联网 发布:分布式数据库产品 编辑:程序博客网 时间:2024/06/03 21:04
如果要将查询结果导出到Excel,只需将页面的Context-Type修改一下就可以了:
header( "Content-Type: application/vnd.ms-excel">
如果希望能够提供那个打开/保存的对话框,Content-Disposition参数,Content-Disposition参数本来是为了在客户端另存文件时提供一个建议的文件名,但是考虑到安全的原因,就从规范中去掉了这个参数
Content-Disposition参数:
attachment --- 作为附件下载
inline --- 在线打开
具体使用如:header("Content-Disposition: inline; filename=文件名.mp3");
Header("Content-Disposition:attachment;filename=test.xls");
其实IE是根据Content-Disposition中filename这个段中文件名的后缀来识别这个文件类型的,所以,
如果有很多种文件类型的时候,可以将Content-Type设置为二进制模式的:
Header("Content-type: application/octet-stream");
示例:
<?
$filename = './download/d.rar ';
$filesize = filesize($filename);
header( "Content-Type: application/force-download ");
header( "Content-Disposition: attachment; filename= ".basename($filename));
header( "Content-Length: ".$filesize);
$data = file_get_contents($filename);
echo $data;
?>
这段代码的意识是打开页面后立即出现下载保存窗口,下载的文件为$filename,
摘取了常用的部分,其实还有其他一些
$mimetypes = array(
'doc' => 'application/msword',
'bin' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'so' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'pdf' => 'application/pdf',
'ai' => 'application/postscript',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'dir' => 'application/x-director',
'js' => 'application/x-javascript',
'swf' => 'application/x-shockwave-flash',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => 'application/zip',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mp3' => 'audio/mpeg',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'wav' => 'audio/x-wav',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'png' => 'image/png',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',
'txt' => 'text/plain',
'xsl' => 'text/xml',
'xml' => 'text/xml',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie',
);
header( "Content-Type: application/vnd.ms-excel">
如果希望能够提供那个打开/保存的对话框,Content-Disposition参数,Content-Disposition参数本来是为了在客户端另存文件时提供一个建议的文件名,但是考虑到安全的原因,就从规范中去掉了这个参数
Content-Disposition参数:
attachment --- 作为附件下载
inline --- 在线打开
具体使用如:header("Content-Disposition: inline; filename=文件名.mp3");
Header("Content-Disposition:attachment;filename=test.xls");
其实IE是根据Content-Disposition中filename这个段中文件名的后缀来识别这个文件类型的,所以,
如果有很多种文件类型的时候,可以将Content-Type设置为二进制模式的:
Header("Content-type: application/octet-stream");
示例:
<?
$filename = './download/d.rar ';
$filesize = filesize($filename);
header( "Content-Type: application/force-download ");
header( "Content-Disposition: attachment; filename= ".basename($filename));
header( "Content-Length: ".$filesize);
$data = file_get_contents($filename);
echo $data;
?>
这段代码的意识是打开页面后立即出现下载保存窗口,下载的文件为$filename,
摘取了常用的部分,其实还有其他一些
$mimetypes = array(
'doc' => 'application/msword',
'bin' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'so' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'pdf' => 'application/pdf',
'ai' => 'application/postscript',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'dir' => 'application/x-director',
'js' => 'application/x-javascript',
'swf' => 'application/x-shockwave-flash',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => 'application/zip',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mp3' => 'audio/mpeg',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'wav' => 'audio/x-wav',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'png' => 'image/png',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',
'txt' => 'text/plain',
'xsl' => 'text/xml',
'xml' => 'text/xml',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie',
);
- header( "Content-Type: application/vnd.ms-excel")
- Content-Type: application/vnd.ms-excel">
- Content-Type: application/vnd.ms-excel
- header( "Content-Type: application/vnd.ms-excel")
- Response.ContentType = "application/vnd.ms-excel"
- 关于Excel表格导出方法--application/vnd.ms-excel
- vnd.ms-excel.numberformat:@"
- vnd.ms-excel.numberformat 导出Ecxel 格式
- vnd.ms-excel.numberformat 导出Ecxel 格式
- 关于Translation failed for content-type:text/vnd.wap.wml的解决方法
- Content-Type: application/x-www-form-urlencoded
- HTTP Header('Content-Type:application/xxx')
- springmvc 设置content-type为 application/json
- .net 导出excel方法,内容自动识别科学计数法去除方式style= 'vnd.ms-excel.numberformat:@ '
- 关于 Content-Type:application/x-www-form-urlencoded 和 Content-Type:multipart/related
- 关于 Content-Type:application/x-www-form-urlencoded 和 Content-Type:multipart/related
- 关于 Content-Type:application/x-www-form-urlencoded 和 Content-Type:multipart/related
- 关于 Content-Type:application/x-www-form-urlencoded 和 Content-Type:multipart/related
- Android图片处理(Matrix,ColorMatrix)
- 项目里使用Extjs
- 解决中文乱码问题
- 遍历二叉树
- Xen:很全的初学者指南
- Content-Type: application/vnd.ms-excel">
- C#异步调用四大方法详解
- C#中的抽象类、抽象方法和虚方法
- WebProject项目手动配置Axis2
- linux下软件安装方法总结
- Difference between RegularEnumSet and JumboEnumSet in Java
- 做微博营销的内容要与传播紧密结合
- 机房收费系统——谈谈MSHFlexGrid 控件的那些事儿
- VC获取DOS命令返回值