WORD:

<?php
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
//有了这些,可以把带html标签的html源码导入到word里,并且可以保持html的样式。
/*
<STYLE>
BR.page { page-break-after: always }
</STYLE>
在<head>部分加这个是为了实现打印的时候分页
*/
$wordStr = '<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<STYLE>
BR.page { page-break-after: always }
</STYLE>
</head><body>'; $wordStr = "<b>hello</b><p>this is html code</p>"; $wordStr .= '</body></html>';
//防止导出乱码
$file = iconv("utf-8", "GBK", $filename); header("Content-Type: application/doc");
header("Content-Disposition: attachment; filename=" . $file . ".doc");
echo $wordStr;
?>

CVS:

<?php
header("Content-Disposition: attachment; filename=邮寄地址.csv");
echo "姓名,性别,年龄,电话\n张三,男,23,15010125818";
?>

注:echo中的逗号是每个列的分割标识符,\n则是换行。

还有如下可参考:

header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");

PDF:

<?php
header("Content-type:application/pdf"); // 文件将被称为 downloaded.pdf
header("Content-Disposition:attachment;filename='downloaded.pdf'"); // PDF 源在 original.pdf 中
readfile("original.pdf");
?> <html>
<body> ...
...

最新文章

  1. 后缀.jar的是什么文件?
  2. struts2总结三:struts2配置文件struts.xml的简单总结
  3. [转]C++ DLL远程注入与卸载函数
  4. Titanium系列--我常用的Titanium的快捷键(持续更新中。。)
  5. URAL 1549 Another Japanese Puzzle(构造)
  6. PHP 错误与异常 笔记与总结(14 )记录和发送异常信息
  7. CSS的基本操作
  8. 基础面试题——Javascript
  9. debian下安装AMD驱动
  10. 工作流管理系统 jBPM
  11. 【Beta阶段】第七次scrum meeting
  12. linux route 路由设置小记
  13. P1451 求细胞数量
  14. Linux 目录结构和常用命令
  15. Vue 中 diff 算法后更新 DOM 的方法
  16. Python数据类型的内置函数之list(列表)
  17. vmware平台下两次网络不通的诡异事件
  18. gcc库链接
  19. Omi框架学习之旅 - 插件机制之omi-transform及原理说明
  20. ionic创建项目失败

热门文章

  1. bzoj 3275 最小割
  2. ZOJ 3623 Battle Ships DP
  3. Loadrunner问题:Monitor name :Windows Resources. Cannot create measurement Processor|% Processor Time|_Total on machine 192.168.0.1
  4. js ajax post 提交的时候后台接收不到参数,但是代码没有错,怎么回事
  5. Backup your Android without root or custom recovery -- adb backup
  6. DotNet_Performance_Tuning_ANTS_Performance_Profiler
  7. [Node.js]OS模块
  8. 安装openldap
  9. EasyUI相同的Tab只打开一个(即EasyUI方法的调用方法)
  10. FizzBuzzWhizz问题python解法