StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
this.dg_Test.RenderControl(htw);
Response.ContentType = "appliction/ms-excel";
Response.AddHeader("ContentDisposition", "online;test.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");
Response.Write(sw.ToString());
这样的代码,运行后还是提示下载文档。为什么不能直接在线打开?
HtmlTextWriter htw = new HtmlTextWriter(sw);
this.dg_Test.RenderControl(htw);
Response.ContentType = "appliction/ms-excel";
Response.AddHeader("ContentDisposition", "online;test.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");
Response.Write(sw.ToString());
这样的代码,运行后还是提示下载文档。为什么不能直接在线打开?
string strFile="F:\\a.doc";
Response.Clear();
Response.ClearHeaders();
Response.Charset = "GB2312";
Response.ContentEncoding =System.Text.Encoding.UTF8;
Response.ContentType = "application/msword";
Response.WriteFile(strFile);