protected void btnToExcel_Click(object sender, EventArgs e)
{
Response.Clear();
Response.BufferOutput = true; Response.Charset = "GB2312"; Response.AppendHeader("Content-Disposition", "attachment;filename=FileName.xls"); Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
//设置导出文件格式
Response.ContentType = "application/ms-excel"; Response.Write("<meta http-equiv=Content-Type content=\"text/html;charset=GB2312\">"); //关闭ViewState
GridView1.EnableViewState = false; System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("ZH-CN", true);
System.IO.StringWriter stringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter textWriter = new System.Web.UI.HtmlTextWriter(stringWriter); pds.AllowPaging = false;
bind();
GridView1.RenderControl(textWriter);
//把HTML写回浏览器
Response.Write(stringWriter.ToString());
Response.End(); pds.AllowPaging = true;
bind(); }
在GridView中有连接 我想把导出后的Excel里的连接去掉(只导出文本内容,不导连接功能)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货