protected void btndaochu1_Click(object sender, EventArgs e)
{
Export("application/ms-excel", "学生资料报表.xls");
}
public void Export(string FileType, string FileName)
{
Response.ClearContent();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
MyGridView.AllowPaging = false;
MyGridView.Columns[10].Visible = false;
MyGridView.Columns[0].Visible = false;
bind();
MyGridView.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
MyGridView.AllowPaging = true;
bind();
}
public override void VerifyRenderingInServerForm(Control control)
{
}