Ejemplo n.º 1
0
 protected void ExcelBt_Click(object sender, EventArgs e)
 {
     ActivitySerachCondition searchCondition = this.Session["ActivitySerachCondition"] as ActivitySerachCondition;
     ActivityBLL ybll = new ActivityBLL();
     Page<ActivityInvo> page = new Page<ActivityInvo>();
     page = ybll.GetActivityList(searchCondition, 0, true);
     List<ActivityInvo> list = new List<ActivityInvo>();
     if ((page != null) && (page.Data != null))
     {
         list = page.Data.ToList<ActivityInvo>();
     }
     if ((list != null) && (list.Count > 0))
     {
         ExcelEdit exelTools = new ExcelEdit();
         exelTools.CreateExcel();
         exelTools.WriteActivityList(list, 0, list.Count - 1);
         Random random = new Random();
         string fileName = base.Server.MapPath(".") + "/ActivityList_" + random.Next(1000).ToString() + ".xls";
         exelTools.ExplortExcel(fileName);
         this.ImportExcel(fileName, exelTools);
     }
 }