/// <summary>
    /// 导出各种文档文件
    /// </summary>
    public static class Export
    {
        /// <summary>
        /// 导出Excel文档
        /// </summary>
        /// <param name="page">网页对象</param>
        /// <param name="gridView">GridView对象</param>
        /// <param name="fileName">文件名</param>
        public static void ToExcel(this Page page, GridView gridView, string fileName)
        {
            page.Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
            page.Response.ContentType = "application/ms-excel";
            page.Response.Charset = "gb2312";
            page.Response.ContentEncoding = Encoding.GetEncoding("gb2312");
            System.IO.StringWriter writer = new System.IO.StringWriter();
            for (int i = 0; i < gridView.Rows.Count; i++)
            {
                for (int j = 0; j < gridView.Rows[i].Cells.Count; j++)
                {
                    writer.Write(gridView.Rows[i].Cells[j].Text);
                    writer.Write("\t");
                }
                writer.WriteLine();
            }
            page.Response.Write(writer.ToString());
            page.Response.End();
        }
    }