Npoi导入导出Execl
2015-07-16 10:48
92 查看
读取csv格式时内容含有逗号的无法处理
web下载
protected void downloadfile(DataTable dd, string s_path) { #region 下载服务器上生成的execl文件 System.IO.FileInfo file = new System.IO.FileInfo(s_path); HttpContext.Current.Response.ContentType = "application/ms-download"; HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("Content-Type", "application/octet-stream"); HttpContext.Current.Response.Charset = "utf-8"; HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8)); HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString()); HttpContext.Current.Response.WriteFile(file.FullName); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.Clear(); //下载完成后删除服务器下生成的文件 if (File.Exists(s_path)) { File.Delete(s_path); } HttpContext.Current.Response.End(); ; #endregion #region 将二进制字符串数组写入输出流 HttpContext.Current.Response.ContentType = "application/ms-download"; HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("Content-Type", "application/octet-stream"); HttpContext.Current.Response.Charset = "utf-8"; HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode("222.xls", Encoding.UTF8));//222.xls下载是默认文件名 HttpContext.Current.Response.BinaryWrite(ProductBLL.download.ExcelHelper.TableToExcel(dd,"xls").GetBuffer()); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.End(); #endregion
web下载
相关文章推荐
- cc_美团 商品详情图片放大显示ViewPager
- Linux内核模块的编译基础知识
- javap -c命令详解
- 《Spring技术内幕》学习笔记1——IoC容器体系结构
- 《Spring技术内幕》学习笔记2——IoC定位Bean定义资源
- 【求职必备】知名互联网公司常见面试问题和应答策略--通用篇
- 拉伸按钮背景图片:stretchableImageWithLeftCapWidth:
- 1.6 文件依赖中的占位符的用法
- commons configuration的简单使用和说明
- {Latex}{Tabular}文本超出表格自动换行
- linux select 学习
- #leetcode#Product of Array Except Self
- mysql如收集统计信息
- 优衣库视频门危机公关被批不合格
- C++实现简易log日志系统
- Jump Game
- asp.net web生命周期和viewstate和loadpostdata小记
- Connection is read-only. Queries leading to data modification are not allowed
- Vert.x-web的讲解和使用(英文原版)
- pip install 报错:Microsoft Visual C++ 9.0 is required Unable to find vcvarsall.bat