Exemple #1
0
        public static void GridViewToExcel(DataSet MyData, Hashtable nameList, string ReportTitle)
        {
            string FilePath = System.Web.HttpContext.Current.Server.MapPath("../") + "ReportFile\\";

            if (!Directory.Exists(FilePath))
            {
                Directory.CreateDirectory(FilePath);
            }
            //利用excel对象
            DataToExcel dte      = new DataToExcel();
            string      filename = "";

            try
            {
                if (MyData.Tables[0].Rows.Count > 0)
                {
                    filename = dte.DataExcel(MyData.Tables[0], ReportTitle, FilePath, nameList);
                }
            }
            catch
            { }
            if (filename != "")
            {
                System.Web.HttpContext.Current.Response.Redirect("../ReportFile/" + filename, true);
            }
        }
Exemple #2
0
 public static void GridViewToExcel(DataSet MyData, Hashtable nameList, string ReportTitle)
 {
     string FilePath = System.Web.HttpContext.Current.Server.MapPath("../") + "ReportFile\\";
     if (!Directory.Exists(FilePath))
     {
         Directory.CreateDirectory(FilePath);
     }
     //利用excel对象
     DataToExcel dte = new DataToExcel();
     string filename = "";
     try
     {
         if (MyData.Tables[0].Rows.Count > 0)
         {
             filename = dte.DataExcel(MyData.Tables[0], ReportTitle, FilePath, nameList);
         }
     }
     catch
     { }
     if (filename != "")
     {
         System.Web.HttpContext.Current.Response.Redirect("../ReportFile/" + filename, true);
     }
 }