| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.IO; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using System.Web; | 
					
						
							|  |  |  |  | using System.Web.UI; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | using BLL; | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  | using FineUIPro.Web.HSSE.License; | 
					
						
							|  |  |  |  | using Microsoft.Office.Interop.Word; | 
					
						
							|  |  |  |  | using Model; | 
					
						
							|  |  |  |  | using NPOI.SS.Formula.Functions; | 
					
						
							| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  | using AspNet = System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.JDGL.Check | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class MonthPlanStatisc : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         private static List<Model.JDGL_MonthPlan> StatisticsList = new List<Model.JDGL_MonthPlan>(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.txtMonths.Text = string.Format("{0:yyyy-MM}", DateTime.Now); | 
					
						
							| 
									
										
										
										
											2025-03-14 12:45:42 +08:00
										 |  |  |  |                 this.txtYear.Text = string.Format("{0:yyyy}", DateTime.Now); | 
					
						
							| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  |                 BindStatisc(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         protected void btnSearch_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (string.IsNullOrEmpty(this.txtMonths.Text.Trim())) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Alert.ShowInTop("月份不能为空!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             BindStatisc(); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-03-14 12:45:42 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  |         #region 绑定GridView | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 绑定 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="cNProfessionalId"></param> | 
					
						
							|  |  |  |  |         public void BindStatisc() | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |             var cycle = this.ckCycle.SelectedValue; | 
					
						
							| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  |             StatisticsList = new List<Model.JDGL_MonthPlan>(); | 
					
						
							|  |  |  |  |             int i = 1; | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             //周期集合 | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |             List<JDGL_MonthPlan> totalList = new List<JDGL_MonthPlan>(); | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             //累计集合 | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |             List<JDGL_MonthPlan> sumTotalList = new List<JDGL_MonthPlan>(); | 
					
						
							|  |  |  |  |             if (cycle == "1") | 
					
						
							|  |  |  |  |             {//按月 | 
					
						
							|  |  |  |  |                 DateTime months = Convert.ToDateTime(this.txtMonths.Text + "-01"); | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                 //周期集合 | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |                 totalList = (from x in db.JDGL_MonthPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.Months == months select x).ToList(); | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                 //累计集合 | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |                 sumTotalList = (from x in db.JDGL_MonthPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.Months <= months select x).ToList(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (cycle == "2") | 
					
						
							|  |  |  |  |             {//按年(以上一年度12月份至本年度11月份为一个周期) | 
					
						
							|  |  |  |  |                 DateTime sDate = Convert.ToDateTime(this.txtYear.Text + "-12-01").AddYears(-1); | 
					
						
							|  |  |  |  |                 DateTime eDate = Convert.ToDateTime(this.txtYear.Text + "-12-01"); | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                 //周期集合 | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |                 totalList = (from x in db.JDGL_MonthPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.Months >= sDate && x.Months < eDate select x).ToList(); | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                 //累计集合 | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |                 sumTotalList = (from x in db.JDGL_MonthPlan where x.ProjectId == this.CurrUser.LoginProjectId  && x.Months < eDate select x).ToList(); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             else if (cycle == "3") | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |             {//按项目周期 | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                 //周期集合 | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |                 totalList = (from x in db.JDGL_MonthPlan where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList(); | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                 //累计集合 | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |                 sumTotalList = (from x in db.JDGL_MonthPlan where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList(); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             ////周期集合 | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |             //var totalList = from x in db.JDGL_MonthPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.Months == months select x; | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             ////累计集合 | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |             //var sumTotalList = from x in db.JDGL_MonthPlan where x.ProjectId == this.CurrUser.LoginProjectId && x.Months <= months select x; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  |             if (this.ckType.SelectedValue == "1")  //按责任单位 | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var pUnit = from x in db.Project_ProjectUnit | 
					
						
							|  |  |  |  |                             join y in db.Base_Unit on x.UnitId equals y.UnitId | 
					
						
							|  |  |  |  |                             where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitType == BLL.Const.ProjectUnitType_2 | 
					
						
							|  |  |  |  |                             orderby y.UnitCode | 
					
						
							|  |  |  |  |                             select y; | 
					
						
							|  |  |  |  |                 foreach (var item in pUnit) | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                     //周期集合 | 
					
						
							| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  |                     var list = totalList.Where(x => x.UnitId == item.UnitId); | 
					
						
							|  |  |  |  |                     Model.JDGL_MonthPlan JDGL_MonthPlan = new Model.JDGL_MonthPlan(); | 
					
						
							|  |  |  |  |                     JDGL_MonthPlan.NodeContent = item.UnitName; | 
					
						
							|  |  |  |  |                     int a = list.Count(); | 
					
						
							|  |  |  |  |                     int b = list.Count(x => x.RealDate.HasValue); | 
					
						
							|  |  |  |  |                     JDGL_MonthPlan.UnitId = a.ToString(); | 
					
						
							|  |  |  |  |                     JDGL_MonthPlan.DutyPerson = b.ToString(); | 
					
						
							|  |  |  |  |                     if (a != 0)//被除数不能为零 | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         JDGL_MonthPlan.Remark = Math.Round((double)b / (double)a * 100, 2) + "%";//保留两位小数、后四舍五入 | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         JDGL_MonthPlan.Remark = "0%"; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     StatisticsList.Add(JDGL_MonthPlan); | 
					
						
							|  |  |  |  |                     i++; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else   //按五环责任人 | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                 var users = UserService.GetUserList(); | 
					
						
							|  |  |  |  |                 var dutyPersonIds = (from x in db.JDGL_MonthPlan | 
					
						
							|  |  |  |  |                                      where x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                      select x.DutyPerson).Distinct().ToList(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 var userIds = string.Join(",", dutyPersonIds.ToArray()).Split(',').Distinct().Where(x => x != null && x != "").ToList(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 //var user = (from x in db.Sys_User | 
					
						
							|  |  |  |  |                 //            join y in db.JDGL_MonthPlan on x.UserId equals y.DutyPerson | 
					
						
							|  |  |  |  |                 //            where y.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                 //            orderby x.UserId | 
					
						
							|  |  |  |  |                 //            select x).Distinct().ToList(); | 
					
						
							|  |  |  |  |                 foreach (var item in userIds) | 
					
						
							| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                     var user = users.Where(x => x.UserId == item).FirstOrDefault(); | 
					
						
							|  |  |  |  |                     //周期集合 | 
					
						
							|  |  |  |  |                     var list = totalList.Where(x => x.DutyPerson.Contains(item)); | 
					
						
							| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  |                     Model.JDGL_MonthPlan JDGL_MonthPlan = new Model.JDGL_MonthPlan(); | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |                     JDGL_MonthPlan.NodeContent = user.UserName; | 
					
						
							| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  |                     int a = list.Count(); | 
					
						
							|  |  |  |  |                     int b = list.Count(x => x.RealDate.HasValue); | 
					
						
							|  |  |  |  |                     JDGL_MonthPlan.UnitId = a.ToString(); | 
					
						
							|  |  |  |  |                     JDGL_MonthPlan.DutyPerson = b.ToString(); | 
					
						
							|  |  |  |  |                     if (a != 0)//被除数不能为零 | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         JDGL_MonthPlan.Remark = Math.Round((double)b / (double)a * 100, 2) + "%";//保留两位小数、后四舍五入 | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         JDGL_MonthPlan.Remark = "0%"; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     StatisticsList.Add(JDGL_MonthPlan); | 
					
						
							|  |  |  |  |                     i++; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2024-07-15 15:11:50 +08:00
										 |  |  |  |             if (StatisticsList.Count() > 0)   //增加合计 | 
					
						
							| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.JDGL_MonthPlan StatisticsLast = new Model.JDGL_MonthPlan(); | 
					
						
							|  |  |  |  |                 StatisticsLast.NodeContent = "合计"; | 
					
						
							|  |  |  |  |                 int a = totalList.Count(); | 
					
						
							|  |  |  |  |                 int b = totalList.Count(x => x.RealDate.HasValue); | 
					
						
							|  |  |  |  |                 StatisticsLast.UnitId = a.ToString(); | 
					
						
							|  |  |  |  |                 StatisticsLast.DutyPerson = b.ToString(); | 
					
						
							|  |  |  |  |                 if (a != 0)//被除数不能为零 | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     StatisticsLast.Remark = Math.Round((double)b / (double)a * 100, 2) + "%";//保留两位小数、后四舍五入 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     StatisticsLast.Remark = "0%"; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 StatisticsList.Add(StatisticsLast); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-03-24 14:21:16 +08:00
										 |  |  |  |             ////增加累计 | 
					
						
							|  |  |  |  |             //Model.JDGL_MonthPlan StatisticsSum = new Model.JDGL_MonthPlan(); | 
					
						
							|  |  |  |  |             //StatisticsSum.NodeContent = "累计"; | 
					
						
							|  |  |  |  |             //int c = sumTotalList.Count(); | 
					
						
							|  |  |  |  |             //int d = sumTotalList.Count(x => x.RealDate.HasValue); | 
					
						
							|  |  |  |  |             //StatisticsSum.UnitId = c.ToString(); | 
					
						
							|  |  |  |  |             //StatisticsSum.DutyPerson = d.ToString(); | 
					
						
							|  |  |  |  |             //if (c != 0)//被除数不能为零 | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    StatisticsSum.Remark = Math.Round((double)d / (double)c * 100, 2) + "%";//保留两位小数、后四舍五入 | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |             //else | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    StatisticsSum.Remark = "0%"; | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |             //StatisticsList.Add(StatisticsSum); | 
					
						
							| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  |             this.Grid1.DataSource = StatisticsList; | 
					
						
							|  |  |  |  |             this.Grid1.DataBind(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							| 
									
										
										
										
											2025-03-14 12:45:42 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 统计周期 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void ckCycle_SelectedIndexChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var cycle = this.ckCycle.SelectedValue; | 
					
						
							|  |  |  |  |             if (cycle == "1") | 
					
						
							|  |  |  |  |             {//按月份 | 
					
						
							|  |  |  |  |                 this.txtMonths.Hidden = false; | 
					
						
							|  |  |  |  |                 this.txtYear.Hidden = true; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-03-14 20:12:23 +08:00
										 |  |  |  |             else if (cycle == "2") | 
					
						
							| 
									
										
										
										
											2025-03-14 12:45:42 +08:00
										 |  |  |  |             {//按年份 | 
					
						
							|  |  |  |  |                 this.txtMonths.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtYear.Hidden = false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             {//按项目周期 | 
					
						
							|  |  |  |  |                 this.txtMonths.Hidden = true; | 
					
						
							|  |  |  |  |                 this.txtYear.Hidden = true; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             BindStatisc(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 统计汇总 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							| 
									
										
										
										
											2024-05-10 15:46:52 +08:00
										 |  |  |  |         protected void ckType_SelectedIndexChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (this.ckType.SelectedValue == "1") | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.Grid1.Columns[1].HeaderText = "责任单位"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 this.Grid1.Columns[1].HeaderText = "五环责任人"; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             BindStatisc(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             BindStatisc(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #region 导出按钮 | 
					
						
							|  |  |  |  |         /// 导出按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnOut_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //string rootPath = Server.MapPath("~/"); | 
					
						
							|  |  |  |  |             //string initTemplatePath = Const.JDGL_MonthPlanTemlUrl; | 
					
						
							|  |  |  |  |             //string uploadfilepath = string.Empty; | 
					
						
							|  |  |  |  |             //string newUrl = string.Empty; | 
					
						
							|  |  |  |  |             //uploadfilepath = rootPath + initTemplatePath; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //if (StatisticsList != null) | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    string projectName = BLL.ProjectService.GetShortNameByProjectId(this.CurrUser.LoginProjectId); | 
					
						
							|  |  |  |  |             //    newUrl = uploadfilepath.Replace("NCR统计模板", "NCR统计(" + projectName + DateTime.Now.ToString("yyyyMMdd") + ")"); | 
					
						
							|  |  |  |  |             //    File.Copy(uploadfilepath, newUrl); | 
					
						
							|  |  |  |  |             //    // 第一步:读取文件流 | 
					
						
							|  |  |  |  |             //    NPOI.SS.UserModel.IWorkbook workbook; | 
					
						
							|  |  |  |  |             //    using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read)) | 
					
						
							|  |  |  |  |             //    { | 
					
						
							|  |  |  |  |             //        //workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream); | 
					
						
							|  |  |  |  |             //        workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(stream); | 
					
						
							|  |  |  |  |             //    } | 
					
						
							|  |  |  |  |             //    // 创建单元格样式 | 
					
						
							|  |  |  |  |             //    NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle(); | 
					
						
							|  |  |  |  |             //    cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; | 
					
						
							|  |  |  |  |             //    cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; | 
					
						
							|  |  |  |  |             //    cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; | 
					
						
							|  |  |  |  |             //    cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; | 
					
						
							|  |  |  |  |             //    cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; | 
					
						
							|  |  |  |  |             //    cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; | 
					
						
							|  |  |  |  |             //    cellStyle.WrapText = true;//自动换行 | 
					
						
							|  |  |  |  |             //    var font = workbook.CreateFont(); | 
					
						
							|  |  |  |  |             //    font.FontHeightInPoints = 11; | 
					
						
							|  |  |  |  |             //    cellStyle.SetFont(font); | 
					
						
							|  |  |  |  |             //    // 第二步:创建新数据行 | 
					
						
							|  |  |  |  |             //    NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0); | 
					
						
							|  |  |  |  |             //    NPOI.SS.UserModel.IRow row = sheet.GetRow(0); | 
					
						
							|  |  |  |  |             //    NPOI.SS.UserModel.ICell cell; | 
					
						
							|  |  |  |  |             //    int i = 2; | 
					
						
							|  |  |  |  |             //    foreach (var item in StatisticsList) | 
					
						
							|  |  |  |  |             //    { | 
					
						
							|  |  |  |  |             //        // 第二步:创建新数据行 | 
					
						
							|  |  |  |  |             //        row = sheet.CreateRow(i); | 
					
						
							|  |  |  |  |             //        // 添加数据 | 
					
						
							|  |  |  |  |             //        cell = row.CreateCell(0); | 
					
						
							|  |  |  |  |             //        cell.CellStyle = cellStyle; | 
					
						
							|  |  |  |  |             //        cell.SetCellValue(item.WorkName);//工作名称 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //        cell = row.CreateCell(1); | 
					
						
							|  |  |  |  |             //        cell.CellStyle = cellStyle; | 
					
						
							|  |  |  |  |             //        cell.SetCellValue(item.CheckNum); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //        cell = row.CreateCell(2); | 
					
						
							|  |  |  |  |             //        cell.CellStyle = cellStyle; | 
					
						
							|  |  |  |  |             //        cell.SetCellValue(item.OKNum); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //        cell = row.CreateCell(3); | 
					
						
							|  |  |  |  |             //        cell.CellStyle = cellStyle; | 
					
						
							|  |  |  |  |             //        cell.SetCellValue(item.NotOKNum); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //        cell = row.CreateCell(4); | 
					
						
							|  |  |  |  |             //        cell.CellStyle = cellStyle; | 
					
						
							|  |  |  |  |             //        cell.SetCellValue(item.OKRate); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //        cell = row.CreateCell(5); | 
					
						
							|  |  |  |  |             //        cell.CellStyle = cellStyle; | 
					
						
							|  |  |  |  |             //        cell.SetCellValue(item.Remark); | 
					
						
							|  |  |  |  |             //        i++; | 
					
						
							|  |  |  |  |             //    } | 
					
						
							|  |  |  |  |             //    // 第三步:写入文件流 | 
					
						
							|  |  |  |  |             //    using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write)) | 
					
						
							|  |  |  |  |             //    { | 
					
						
							|  |  |  |  |             //        workbook.Write(stream); | 
					
						
							|  |  |  |  |             //        workbook.Close(); | 
					
						
							|  |  |  |  |             //    } | 
					
						
							|  |  |  |  |             //    string fileName = Path.GetFileName(newUrl); | 
					
						
							|  |  |  |  |             //    FileInfo info = new FileInfo(newUrl); | 
					
						
							|  |  |  |  |             //    long fileSize = info.Length; | 
					
						
							|  |  |  |  |             //    Response.Clear(); | 
					
						
							|  |  |  |  |             //    Response.ContentType = "application/x-zip-compressed"; | 
					
						
							|  |  |  |  |             //    Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); | 
					
						
							|  |  |  |  |             //    Response.AddHeader("Content-Length", fileSize.ToString()); | 
					
						
							|  |  |  |  |             //    Response.TransmitFile(newUrl, 0, fileSize); | 
					
						
							|  |  |  |  |             //    Response.Flush(); | 
					
						
							|  |  |  |  |             //    Response.Close(); | 
					
						
							|  |  |  |  |             //    File.Delete(newUrl); | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |             //else | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    Alert.ShowInTop("当前无记录,无法导出!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 导出方法 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="grid"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         //private string GetGridTableHtml(Grid grid) | 
					
						
							|  |  |  |  |         //{ | 
					
						
							|  |  |  |  |         //    StringBuilder sb = new StringBuilder(); | 
					
						
							|  |  |  |  |         //    sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>"); | 
					
						
							|  |  |  |  |         //    sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">"); | 
					
						
							|  |  |  |  |         //    sb.Append("<tr>"); | 
					
						
							|  |  |  |  |         //    grid.PageSize = 10000; | 
					
						
							|  |  |  |  |         //    BindStatisc(); | 
					
						
							|  |  |  |  |         //    foreach (GridColumn column in grid.Columns) | 
					
						
							|  |  |  |  |         //    { | 
					
						
							|  |  |  |  |         //        sb.AppendFormat("<td>{0}</td>", column.HeaderText); | 
					
						
							|  |  |  |  |         //    } | 
					
						
							|  |  |  |  |         //    sb.Append("</tr>"); | 
					
						
							|  |  |  |  |         //    foreach (GridRow row in grid.Rows) | 
					
						
							|  |  |  |  |         //    { | 
					
						
							|  |  |  |  |         //        sb.Append("<tr>"); | 
					
						
							|  |  |  |  |         //        foreach (GridColumn column in grid.Columns) | 
					
						
							|  |  |  |  |         //        { | 
					
						
							|  |  |  |  |         //            string html = row.Values[column.ColumnIndex].ToString(); | 
					
						
							|  |  |  |  |         //            if (column.ColumnID == "tfNumber") | 
					
						
							|  |  |  |  |         //            { | 
					
						
							|  |  |  |  |         //                html = (row.FindControl("labNumber") as AspNet.Label).Text; | 
					
						
							|  |  |  |  |         //            } | 
					
						
							|  |  |  |  |         //            sb.AppendFormat("<td>{0}</td>", html); | 
					
						
							|  |  |  |  |         //        } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //        sb.Append("</tr>"); | 
					
						
							|  |  |  |  |         //    } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //    sb.Append("</table>"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //    return sb.ToString(); | 
					
						
							|  |  |  |  |         //} | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |