Response.ClearContent();
Response.Buffer = false;
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//防止乱码
string style = @"<style> .text { mso-number-format:\@; } </style> ";//控制文本格式,防止0丢失
Response.AddHeader("content-disposition", "attachment; filename=MyWord.doc");
Response.ContentType = "application/word";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gridView.AllowPaging = false;
gridView.AllowSorting = false;
BindData1();//再绑定一下数据
gridView.RenderControl(htw);
Response.Write(style);
Response.Write(sw.ToString());
Response.End();
gridView.AllowPaging = true;
gridView.AllowSorting = true;
public override void VerifyRenderingInServerForm(Control control)
{
//base.VerifyRenderingInServerForm(control);
}