public static function header_file($doc,$file,$title,$type='Excel5'){

if(!empty($doc)){

$objWriter = self::writer_excel($doc,$title, $type);    //excel写入方法

header("Content-Type: application/force-download");

header("Content-Type: application/octet-stream");

header("Content-Type: application/download");

//header("Content-Disposition: attachment; filename=".urlencode($file));

$ua = $_SERVER["HTTP_USER_AGENT"];

$encoded_file = urlencode($file);

$encoded_file = str_replace("+", "%20", $encoded_file);

if (preg_match("/MSIE/", $ua)) {

header('Content-Disposition: attachment; filename="' . $encoded_file . '"');

} else if (preg_match("/Firefox/", $ua)) {

header('Content-Disposition: attachment; filename*="utf8\'\'' . $file . '"');

} else {

header('Content-Disposition: attachment; filename="' . $file . '"');

}

header("Content-Transfer-Encoding: binary");

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

header("Cache-Control: must-revalidate, post-check=0, pre-check=0");

header("Pragma: no-cache");

$objWriter->save('php://output');

}

}

}

导出excel部分代码的更多相关文章

  1. asp.net导出excel示例代码

    asp.net导出excel的简单方法. excel的操作,最常用的就是导出和导入. 本例使用NPOI实现. 代码:/// <summary> );             ;       ...

  2. asp.net webform/mvc导出Excel通用代码

    最近将自己在项目中经常用到的excel导出方法分析如下,如有不妥之处望他人指出,如果有更好的方法希望展示出来互相学习. //导出事件 protected void btnexcel_Click(obj ...

  3. poi 导出Excel java代码

    js: function initBatchExport(url,sub_key,current_sub_num){ var btn_id="#btn_char"+current_ ...

  4. 多线程异步导出excel

    先新建一个执行类 @Service public class MultiService { private static final Logger logger = LoggerFactory.get ...

  5. 关于导出Excel

    Asp.Net 在刚毕业那会,做项目全是服务器控件.导出Excel的代码也很简单,在button触发后台事件后,后台生成一个excel文件,然后读取成字节,输出到客户端. Response.AddHe ...

  6. asp.net 导出excel文件

    之前做过winfrom程序的导出excel文件的功能,感觉非常简单.现在试着做asp.net中导出excel的功能,之前用的是Microsoft.Office.Interop.Excel这个对象来实现 ...

  7. gridcontrol显示行号,总行,打印,导出Excel,设置标头及内容居中方法

    1.一般为了表格显示数据更直观,经常会显示行号以及总数.让gridcontrol显示行号,首先你需要设置一下显示行号的宽度,也就是IndicatorWith.默认值为-1,可根据实际数值需要设置宽度, ...

  8. C#导出 Excel 时, 生成 CheckBox 控件

    在使用 Microsoft.Office.Interop.Excel 组件导出Excel 表格时,要把导出前的  CheckBox 控件一同导出到 excel 表格中,对于这个功能 看似很简单,但 M ...

  9. 前端导出Excel

    1.首先,需要下载一个叫better-xlsx,的插件,以yarn 为例 ' yarn add better-xlsx --save '下载相关依赖包( npm 方式 ' npm i better-x ...

随机推荐

  1. Is Anchor magento

    如何在magento分类页的Layered Navigation中可以用magento后台已有的attributes进行筛选. 首先,进入后台 Catalog > Manage Categori ...

  2. {$ecs_css_path}

    includes里的init.php的187-194行 if (!empty($_CFG['stylename'])) { $smarty->assign('ecs_css_path', 'th ...

  3. The Best Path---hdu5883(欧拉路径)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5883 题意:n 个点 m 条无向边的图,找一个欧拉通路/回路使得这个路径所有结点的异或值最大. 先判断 ...

  4. mac下安装使用svn

    mac自带了svn服务端和客户端,所以只需要简单配置一下就可以使用   转自  http://blog.sina.com.cn/s/blog_677fb16e01011i6l.html 1.创建svn ...

  5. 《JAVA NIO》读书笔记

    第一章 简介 第二章 缓冲区 第三章  channel

  6. Hibernate中in语句ids

    Query query=session.createQuery("from User where id in (:ids)"); query.setParameterList(&q ...

  7. Linux命令行–更多bash shell命令(转)

    4.1.1 探查程序 ps 命令 默认情况下,ps命令只会显示运行在当前控制台下的属于当前用户进程的进程 显示的当前进程的项目 进程号 运行在哪个终端(tty) 进程占用的CPU时间 Linux系统支 ...

  8. android关于The connection to adb is down, and a severe error has occured.这个问题的解决办法

    有时在打开模拟器的时候会出现The connection to adb is down, and a severe error has occured.这个问题,这个问题的解决办法有两个: 方法一:找 ...

  9. hadoop 文件系统API操作

    配置参数:-DHADOOP_USER_NAME=hadoop public class HdfsUtils { private static FileSystem fileSystem; @Befor ...

  10. myeclipse WIN7下设置字体列表中无Courier New

    到"C:\Windows\Fonts"下找到对应的字体,单击,选择上面的显示 然后就可以在eclicpse字体设置里面看到Courier New项了: Eclipse字体设置方法: ...