关于导出excel在谷歌浏览器中网络错误的问题
具体代码如下
System.Web.UI.WebControls.GridView DGOutPut = new System.Web.UI.WebControls.GridView();
DGOutPut.Visible = true;
DGOutPut.RowDataBound += new GridViewRowEventHandler(DGOutPut_RowDataBound);
DGOutPut.DataSource = dt;
DGOutPut.DataBind();
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.Buffer = true;
//System.Web.HttpContext.Current.Response.Charset = "GB2312";
//System.Web.HttpContext.Current.Response.Charset = "UTF-8";
System.Web.HttpContext.Current.Response.Charset = "GB2312";
System.Web.HttpContext.Current.Response.ContentEncoding = Encoding.Default;
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName + ".xls", System.Text.Encoding.UTF8));
//System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
//System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
System.Web.HttpContext.Current.Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
DGOutPut.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
DGOutPut.RenderControl(oHtmlTextWriter);
System.Web.HttpContext.Current.Response.Write(@"<style> .text {mso-number-format:\@; } </style> ");
System.Web.HttpContext.Current.Response.Write(oStringWriter.ToString());
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.Close();
//System.Web.HttpContext.Current.Response.End();
//HttpContext.Current.ApplicationInstance.CompleteRequest();
DGOutPut.DataSource = null;
DGOutPut.Visible = false;
...全文
相关推荐
extjs4导出excel
extjs4 导出 excel export ,经过我的一些修正,可以使用,并导出excel,有问题可以联系我,我的博客里有篇博文可以参考
easyui导出excel工具
easyui datagrid 导出excel工具类 快速实现一个datagrid导出excel功能,方便页面开发人员
ext实现导出excel的功能。
可以选择字段导出,也可以排序导出。还可以导出当前页和导出所有的数据。
vue中后端做Excel导出功能返回数据流前端的处理操作
项目中有一个导出功能的实现,用博客来记录一下。因为需求对导出表格的数据格式和样式有要求,所以这个导出功能放到后端来做,而且后端返回的是数据流,所以需要处理成想要的表格并导出来。 先看下效果图: 页面效果: 点击 导出Excel 调用导出接口成功了: 后台返回的数据流,一堆看不懂的乱码: 接下来要处理这堆乱码,因为用到的地方多,所以在util.js文件里封装了一个公共方法并抛出: 虽然vue里有封装好的请求接口的方法,但这里要单独用axios,所以先在util.js里引入axios import axios from ‘axios’ // 导出Excel公用方法 export fun
extjs 导出excel
extjs 导出excelextjs 导出excelextjs 导出excelextjs 导出excelextjs 导出excel



