/// <summary>
    
/// GridView导出Excel
    
/// </summary>
    
/// <param name="pageLocal">要导出的页面</param>
    
/// <param name="gvVal">要导出的GridView</param>
    
/// <param name="sFileName">导出后的文件名</param>
    public static void ExcelExport(Page pageLocal, GridView gvVal, string sFileName)
    {
        
string attachment = "attachment; filename=" + sFileName + ".xls";
        pageLocal.Response.ClearContent();
        pageLocal.Response.AddHeader(
"content-disposition", attachment);
        pageLocal.Response.ContentType 
= "application/ms-excel";
        StringWriter sw 
= new StringWriter();
        HtmlTextWriter htw 
= new HtmlTextWriter(sw);

        
// Create a form to contain the grid
        HtmlForm frm = new HtmlForm();
        gvVal.Parent.Controls.Add(frm);
        frm.Attributes[
"runat"= "server";
        frm.Controls.Add(gvVal);
        frm.RenderControl(htw);

        
//GridView1.RenderControl(htw);
        pageLocal.Response.Write(sw.ToString());
        pageLocal.Response.End();
    }