<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
<META HTTP-EQUIV="expires" CONTENT="0">

=============================

string ExcelHeader = "<html><head><meta http-equiv=Content-Type content=text/html; charset=utf-8><style>td{mso-number-format:\\@}</style></head><body>";
string ExcelFooter = "</body></html>";
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=new.xls");
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
this.dgView.RenderControl(hw);
Response.Write(ExcelHeader + tw.ToString + ExcelFooter);
Response.End();

文章標籤
全站熱搜
創作者介紹
創作者 AndrewHsiao 的頭像
AndrewHsiao

Andrew的部落格

AndrewHsiao 發表在 痞客邦 留言(0) 人氣(0)