protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.ClearContent();
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=sumlate.xls");
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.ContentType = "application/excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
if (GridView1.Rows.Count > 0)
{
GridView1.RenderControl(htw);
}
else
{
GridView1.RenderControl(htw);
}
Response.Write(sw.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
//这个方法不能删除掉
}