using BLL; using NPOI.HSSF.Util; using NPOI.SS.UserModel; using NPOI.SS.Util; using NPOI.XSSF.UserModel; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Globalization; using System.IO; using System.Linq; using System.Web.UI.WebControls; using System.Threading; using Model; namespace FineUIPro.Web.Report { public partial class RolesReport : PageBase { public static int percent { get; set; } public static string url { get; set; } [System.Web.Services.WebMethod] public static int getPercent() { return percent; } [System.Web.Services.WebMethod] public static string getUrl() { return url; } #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { InitGrid(); if (!IsPostBack) { percent = 0; url = ""; GetButtonPower();//权限设置 BindGrid1(); } } private void InitGrid() { GregorianCalendar gc = new GregorianCalendar(); for (int i = -3; i < 2; i++) { DateTime dateTime = new DateTime(DateTime.Now.Year + i, 12, 31); FineUIPro.GroupField gf = new FineUIPro.GroupField(); gf.TextAlign = TextAlign.Center; gf.HeaderText = dateTime.Year + ""; for (int j = 1; j <= gc.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday); j++) { FineUIPro.BoundField bf = new FineUIPro.BoundField(); bf.DataField = dateTime.Year + "-" + j; bf.DataFormatString = "{0}"; bf.HeaderText = "" + j; bf.Width = Unit.Pixel(50); gf.Columns.Add(bf); } Grid4.Columns.Add(gf); } } #endregion #region 点击TAB数据切换 /// /// 点击TAB数据切换 /// protected void TabStrip1_TabIndexChanged(object sender, EventArgs e) { if (TabStrip1.ActiveTabIndex == 0) { this.txtProjectManger.Hidden = false; BindGrid1(); } else if (TabStrip1.ActiveTabIndex == 1) { this.txtProjectManger.Hidden = true; BindGrid2(); } else if (TabStrip1.ActiveTabIndex == 2) { this.txtProjectManger.Hidden = true; BindGrid3(); } else if (TabStrip1.ActiveTabIndex == 3) { this.txtProjectManger.Hidden = true; BindGrid4(); } else if (TabStrip1.ActiveTabIndex == 4) { this.txtProjectManger.Hidden = true; BindGrid5(); } } #endregion #region Over view /// /// 绑定数据 /// private void BindGrid1() { string strSql = @"SELECT * FROM VIEW_Report_Overview WHERE 1=1 "; List listStr = new List(); if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) { strSql += " AND ProjectControl_JobNo LIKE @JobNO "; listStr.Add(new SqlParameter("@JobNO", this.txtJobNo.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtProjectManger.Text.Trim())) { strSql += " AND ProjectControl_ProjectManager LIKE @ProjectManager "; listStr.Add(new SqlParameter("@ProjectManager", "%" + this.txtProjectManger.Text.Trim() + "%")); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); // 2.获取当前分页数据 //var table = this.GetPagedDataTable(Grid1, tb1); Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid1(); } /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid1(); } #endregion #region PermitGeneral /// /// 绑定数据 /// private void BindGrid2() { string strSql = @"SELECT * FROM View_Report_PermitGeneral WHERE 1=1 "; List listStr = new List(); if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) { strSql += " AND ProjectControl_JobNo LIKE @JobNO "; listStr.Add(new SqlParameter("@JobNO", this.txtJobNo.Text.Trim() + "%")); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); // 2.获取当前分页数据 //var table = this.GetPagedDataTable(Grid1, tb1); Grid2.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid2, tb); Grid2.DataSource = table; Grid2.DataBind(); } /// /// 分页 /// /// /// protected void Grid2_PageIndexChange(object sender, GridPageEventArgs e) { Grid2.PageIndex = e.NewPageIndex; BindGrid2(); } /// /// 排序 /// /// /// protected void Grid2_Sort(object sender, FineUIPro.GridSortEventArgs e) { Grid2.SortDirection = e.SortDirection; Grid2.SortField = e.SortField; BindGrid2(); } #endregion #region Permit_Pressure Piping & Vesse /// /// 绑定数据 /// private void BindGrid3() { string strSql = @"SELECT * FROM View_Report_Permit_PressurePipingVesse WHERE 1=1 "; List listStr = new List(); if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) { strSql += " AND ProjectControl_JobNo LIKE @JobNO "; listStr.Add(new SqlParameter("@JobNO", this.txtJobNo.Text.Trim() + "%")); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); // 2.获取当前分页数据 //var table = this.GetPagedDataTable(Grid1, tb1); Grid3.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid3, tb); Grid3.DataSource = table; Grid3.DataBind(); } /// /// 分页 /// /// /// protected void Grid3_PageIndexChange(object sender, GridPageEventArgs e) { Grid3.PageIndex = e.NewPageIndex; BindGrid3(); } /// /// 排序 /// /// /// protected void Grid3_Sort(object sender, FineUIPro.GridSortEventArgs e) { Grid3.SortDirection = e.SortDirection; Grid3.SortField = e.SortField; BindGrid3(); } #endregion #region Schedule_Gantt_Bar /// /// 绑定数据 /// private void BindGrid4() { string strSql = @"SELECT * FROM View_Report_ScheduleGanttBar WHERE 1=1 "; List listStr = new List(); if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) { strSql += " AND ProjectControl_JobNo LIKE @JobNO "; listStr.Add(new SqlParameter("@JobNO", this.txtJobNo.Text.Trim() + "%")); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); GregorianCalendar gc = new GregorianCalendar(); for (int i = -3; i < 2; i++) { DateTime dateTime = new DateTime(DateTime.Now.Year + i, 12, 31); for (int j = 1; j <= gc.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday); j++) { tb.Columns.Add(dateTime.Year + "-" + j, System.Type.GetType("System.String")); } } for (int i = 0; i < tb.Rows.Count; i++) { try { var ReceiveDate = tb.Rows[i]["ReceiveDate"]; var ApprovalDate = tb.Rows[i]["ApprovalDate"]; var ConstStart = tb.Rows[i]["ConstMECivilStart"]; var DEMEEnd = tb.Rows[i]["DEMECivilEnd"]; var ConstEnd = tb.Rows[i]["ConstMECivilEnd"]; if (ReceiveDate is DateTime && ApprovalDate is DateTime) { DateTime start = (DateTime)ReceiveDate; DateTime end = (DateTime)ApprovalDate; for (; start < end; start = start.AddDays(7)) { if (tb.Columns.Contains(start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday))) tb.Rows[i][start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday)] = "A"; } } if (ApprovalDate is DateTime && ConstStart is DateTime) { DateTime start = (DateTime)ApprovalDate; DateTime end = (DateTime)ConstStart; for (; start < end; start = start.AddDays(7)) { if (tb.Columns.Contains(start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday))) tb.Rows[i][start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday)] = "B"; } } if (ConstStart is DateTime && DEMEEnd is DateTime) { DateTime start = (DateTime)ConstStart; DateTime end = (DateTime)DEMEEnd; for (; start < end; start = start.AddDays(7)) { if (tb.Columns.Contains(start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday))) tb.Rows[i][start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday)] = "C"; } } if (DEMEEnd is DateTime && ConstEnd is DateTime) { DateTime start = (DateTime)DEMEEnd; DateTime end = (DateTime)ConstEnd; for (; start < end; start = start.AddDays(7)) { if (tb.Columns.Contains(start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday))) tb.Rows[i][start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday)] = "D"; } } } catch (Exception e) { } } Grid4.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid4, tb); Grid4.DataSource = table; Grid4.DataBind(); } /// /// 分页 /// /// /// protected void Grid4_PageIndexChange(object sender, GridPageEventArgs e) { Grid4.PageIndex = e.NewPageIndex; BindGrid4(); } /// /// 排序 /// /// /// protected void Grid4_Sort(object sender, FineUIPro.GridSortEventArgs e) { Grid4.SortDirection = e.SortDirection; Grid4.SortField = e.SortField; BindGrid4(); } #endregion #region Roles Report /// /// 绑定数据 /// private void BindGrid5() { List listStr = new List(); if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) { listStr.Add(new SqlParameter("@jobno", this.txtJobNo.Text.Trim())); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunProc("Proc_Rolesview", parameter); Grid5.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid5, tb); Grid5.DataSource = table; Grid5.DataBind(); } #region 分页、排序 /// /// 分页 /// /// /// protected void Grid5_PageIndexChange(object sender, GridPageEventArgs e) { Grid5.PageIndex = e.NewPageIndex; BindGrid5(); } /// /// 排序 /// /// /// protected void Grid5_Sort(object sender, FineUIPro.GridSortEventArgs e) { Grid5.SortDirection = e.SortDirection; Grid5.SortField = e.SortField; BindGrid5(); } #endregion #endregion #region 查询 /// /// 查询 /// /// /// protected void btnSearch_Click(object sender, EventArgs e) { if (TabStrip1.ActiveTabIndex == 0) { BindGrid1(); } else if (TabStrip1.ActiveTabIndex == 1) { BindGrid2(); } else if (TabStrip1.ActiveTabIndex == 2) { BindGrid3(); } else if (TabStrip1.ActiveTabIndex == 3) { BindGrid4(); } else if (TabStrip1.ActiveTabIndex == 4) { BindGrid5(); } } #endregion #region 导出 /// /// 导出按钮 /// /// /// protected void btnExport_Click(object sender, EventArgs e) { percent = 0; url = ""; var OverviewReport = (from x in Funs.DB.VIEW_Report_Overview orderby x.ProjectControl_JobNo descending select x).ToList(); if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) { OverviewReport = OverviewReport.Where(x => x.ProjectControl_JobNo.StartsWith(this.txtJobNo.Text.Trim())).ToList(); } if (!string.IsNullOrEmpty(this.txtProjectManger.Text.Trim())) { OverviewReport = OverviewReport.Where(x => x.ProjectControl_ProjectManager.StartsWith(this.txtProjectManger.Text.Trim())).ToList(); } var Permit_General = (from x in Funs.DB.View_Report_PermitGeneral orderby x.ProjectControl_JobNo descending select x).ToList(); if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) { Permit_General = Permit_General.Where(x => x.ProjectControl_JobNo.StartsWith(this.txtJobNo.Text.Trim())).ToList(); } var PressurePipingVesseReport = (from x in Funs.DB.View_Report_Permit_PressurePipingVesse orderby x.ProjectControl_JobNo descending select x).ToList(); if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) { PressurePipingVesseReport = PressurePipingVesseReport.Where(x => x.ProjectControl_JobNo.StartsWith(this.txtJobNo.Text.Trim())).ToList(); } string strSql = @"SELECT * FROM View_Report_ScheduleGanttBar WHERE 1=1 "; List listStr = new List(); if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) { strSql += " AND ProjectControl_JobNo LIKE @JobNO "; listStr.Add(new SqlParameter("@JobNO", this.txtJobNo.Text.Trim() + "%")); } strSql += " order by ProjectControl_JobNo desc"; SqlParameter[] parameter = listStr.ToArray(); List listParameters = new List(); if (!string.IsNullOrEmpty(txtJobNo.Text.Trim())) { listParameters.Add(new SqlParameter("@jobno", txtJobNo.Text.Trim())); } SqlParameter[] par = listParameters.ToArray(); Thread t = new Thread(new ThreadStart(() => { Export(strSql, parameter, par, Permit_General, OverviewReport, PressurePipingVesseReport); })); t.Start(); PageContext.RegisterStartupScript("showProcessBar()"); #region //string rootPath = Server.MapPath("~/") + Const.ExcelUrl; ////模板文件 //string TempletFileName = rootPath + "RolesReport.xlsx"; ////导出文件 //string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\"; //if (!Directory.Exists(filePath)) //{ // Directory.CreateDirectory(filePath); //} //string ReportFileName = filePath + "out.xlsx"; //FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read); //XSSFWorkbook hssfworkbook = new XSSFWorkbook(file); //XSSFFont cs_content_Fonts = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 //cs_content_Fonts.FontName = "sans-serif";//字体 //cs_content_Fonts.FontHeightInPoints = 10; //字体大小 //#region 背景色、字体设置 //#region 黄底 ////创建单元格样式 ////XSSFCellStyle backgroundstyle = (XSSFCellStyle)hssfworkbook.CreateCellStyle(); //////填充模式 ////backgroundstyle.FillPattern = FillPattern.SolidForeground; //////创建颜色 ////XSSFColor xssfcolor = new XSSFColor(); //////rbg值 ////byte[] rgbYellow = { (byte)250, (byte)250, (byte)210 }; //////写入rgb ////xssfcolor.SetRgb(rgbYellow); //////设置颜色值 ////backgroundstyle.SetFillForegroundColor(xssfcolor); //#endregion //#region 黄底黑字 backgroundstyle1 ////创建单元格样式 //XSSFCellStyle backgroundstyle1 = (XSSFCellStyle)hssfworkbook.CreateCellStyle(); ////填充模式 //backgroundstyle1.FillPattern = FillPattern.SolidForeground; ////创建颜色 //XSSFColor xssfcolor1 = new XSSFColor(); ////rbg值 //byte[] rgbYellow1 = { (byte)250, (byte)250, (byte)210 }; ////写入rgb //xssfcolor1.SetRgb(rgbYellow1); ////设置颜色值 //backgroundstyle1.SetFillForegroundColor(xssfcolor1); ////创建字体 //XSSFFont red_content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 //red_content_Font.FontName = "sans-serif";//字体 //red_content_Font.FontHeightInPoints = 10; //字体大小 //red_content_Font.Color = HSSFColor.Black.Index;//黑字 //backgroundstyle1.SetFont(red_content_Font); //#endregion //#region 黄底红字 backgroundstyle2 ////创建单元格样式 //XSSFCellStyle backgroundstyle2 = (XSSFCellStyle)hssfworkbook.CreateCellStyle(); ////填充模式 //backgroundstyle2.FillPattern = FillPattern.SolidForeground; ////创建颜色 //XSSFColor xssfcolor2 = new XSSFColor(); ////rbg值 //byte[] rgbYellow2 = { (byte)250, (byte)250, (byte)210 }; ////写入rgb //xssfcolor2.SetRgb(rgbYellow2); ////设置颜色值 //backgroundstyle2.SetFillForegroundColor(xssfcolor2); ////创建字体 //XSSFFont red_content_Font2 = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 //red_content_Font2.FontName = "sans-serif";//字体 //red_content_Font2.FontHeightInPoints = 10; //字体大小 //red_content_Font2.Color = HSSFColor.Red.Index;//黑字 //backgroundstyle2.SetFont(red_content_Font2); //#endregion //#region 红底红字 backgroundstyle3 ////创建单元格样式 //XSSFCellStyle backgroundstyle3 = (XSSFCellStyle)hssfworkbook.CreateCellStyle(); ////填充模式 //backgroundstyle3.FillPattern = FillPattern.SolidForeground; ////创建颜色 //XSSFColor xssfcolor3 = new XSSFColor(); ////rbg值 //byte[] rgbRed3 = { (byte)244, (byte)164, (byte)96 }; ////写入rgb //xssfcolor3.SetRgb(rgbRed3); ////设置颜色值 //backgroundstyle3.SetFillForegroundColor(xssfcolor3); /////创建字体 //XSSFFont red_content_Font3 = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 //red_content_Font3.FontName = "sans-serif";//字体 //red_content_Font3.FontHeightInPoints = 10; //字体大小 //red_content_Font3.Color = HSSFColor.Red.Index; //backgroundstyle3.SetFont(red_content_Font3); //#endregion //#region 白底红字 backgroundstyle4 ////创建单元格样式 //XSSFCellStyle backgroundstyle4 = (XSSFCellStyle)hssfworkbook.CreateCellStyle(); ////填充模式 //backgroundstyle4.FillPattern = FillPattern.SolidForeground; ////创建颜色 //XSSFColor xssfcolor4 = new XSSFColor(); ////rbg值 //byte[] rgbWhite = { (byte)255, (byte)255, (byte)255 };//白色 // //写入rgb //xssfcolor4.SetRgb(rgbWhite); ////设置颜色值 //backgroundstyle4.SetFillForegroundColor(xssfcolor4); /////创建字体 //XSSFFont red_content_Font4 = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 //red_content_Font4.FontName = "sans-serif";//字体 //red_content_Font4.FontHeightInPoints = 10; //字体大小 //red_content_Font4.Color = HSSFColor.Red.Index; //backgroundstyle4.SetFont(red_content_Font4); //#endregion //#region 红底 ////创建单元格样式 //XSSFCellStyle redbackgroundstyle = (XSSFCellStyle)hssfworkbook.CreateCellStyle(); ////填充模式 //redbackgroundstyle.FillPattern = FillPattern.SolidForeground; ////创建颜色 //XSSFColor xssfredcolor = new XSSFColor(); ////rbg值 //byte[] rgbRed = { (byte)244, (byte)164, (byte)96 }; ////写入rgb //xssfredcolor.SetRgb(rgbRed); ////设置颜色值 //redbackgroundstyle.SetFillForegroundColor(xssfredcolor); //#endregion //#endregion //#region Overview //XSSFSheet overview = (XSSFSheet)hssfworkbook.GetSheet("Overview"); //var OverviewReport = (from x in Funs.DB.VIEW_Report_Overview orderby x.ProjectControl_JobNo descending select x).ToList(); //if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) //{ // OverviewReport = OverviewReport.Where(x => x.ProjectControl_JobNo.Contains(this.txtJobNo.Text.Trim())).ToList(); //} //if (!string.IsNullOrEmpty(this.txtProjectManger.Text.Trim())) //{ // OverviewReport = OverviewReport.Where(x => x.ProjectControl_ProjectManager.Contains(this.txtProjectManger.Text.Trim())).ToList(); //} //if (OverviewReport.Count > 0) //{ // var rowIndex = 1; // foreach (var itemOver in OverviewReport) // { // if (overview.GetRow(rowIndex) == null) overview.CreateRow(rowIndex); // #region 列赋值 // if (overview.GetRow(rowIndex).GetCell(0) == null) overview.GetRow(rowIndex).CreateCell(0); // overview.GetRow(rowIndex).GetCell(0).SetCellValue(itemOver.ProjectControl_BUCode); // if (overview.GetRow(rowIndex).GetCell(1) == null) overview.GetRow(rowIndex).CreateCell(1); // overview.GetRow(rowIndex).GetCell(1).SetCellValue(itemOver.ProjectControl_JobNo); // if (overview.GetRow(rowIndex).GetCell(2) == null) overview.GetRow(rowIndex).CreateCell(2); // overview.GetRow(rowIndex).GetCell(2).SetCellValue(itemOver.ProjectControl_JobType); // if (overview.GetRow(rowIndex).GetCell(3) == null) overview.GetRow(rowIndex).CreateCell(3); // overview.GetRow(rowIndex).GetCell(3).SetCellValue(itemOver.ProjectControl_LeadByName); // if (overview.GetRow(rowIndex).GetCell(4) == null) overview.GetRow(rowIndex).CreateCell(4); // overview.GetRow(rowIndex).GetCell(4).SetCellValue(itemOver.ProjectControl_JobTitle); // if (overview.GetRow(rowIndex).GetCell(5) == null) overview.GetRow(rowIndex).CreateCell(5); // overview.GetRow(rowIndex).GetCell(5).SetCellValue(itemOver.ProjectControl_OrginalBudget.HasValue ? string.Format("{0:N}",(float)itemOver.ProjectControl_OrginalBudget) : ""); // if (overview.GetRow(rowIndex).GetCell(6) == null) overview.GetRow(rowIndex).CreateCell(6); // overview.GetRow(rowIndex).GetCell(6).SetCellValue(itemOver.ProjectControl_ProjectManager); // if (overview.GetRow(rowIndex).GetCell(7) == null) overview.GetRow(rowIndex).CreateCell(7); // overview.GetRow(rowIndex).GetCell(7).SetCellValue(itemOver.ProjectControl_ConstManager); // if (overview.GetRow(rowIndex).GetCell(8) == null) overview.GetRow(rowIndex).CreateCell(8); // overview.GetRow(rowIndex).GetCell(8).SetCellValue(itemOver.PM_MA_ProjectApproval); // if (overview.GetRow(rowIndex).GetCell(9) == null) overview.GetRow(rowIndex).CreateCell(9); // overview.GetRow(rowIndex).GetCell(9).SetCellValue(itemOver.ProjectControl_MS_MC); // if (overview.GetRow(rowIndex).GetCell(10) == null) overview.GetRow(rowIndex).CreateCell(10); // overview.GetRow(rowIndex).GetCell(10).SetCellValue(itemOver.MCRevised); // if (overview.GetRow(rowIndex).GetCell(11) == null) overview.GetRow(rowIndex).CreateCell(11); // overview.GetRow(rowIndex).GetCell(11).SetCellValue(itemOver.PM_General_Priority); // if (overview.GetRow(rowIndex).GetCell(12) == null) overview.GetRow(rowIndex).CreateCell(12); // overview.GetRow(rowIndex).GetCell(12).SetCellValue(itemOver.PM_General_Category); // if (overview.GetRow(rowIndex).GetCell(13) == null) overview.GetRow(rowIndex).CreateCell(13); // overview.GetRow(rowIndex).GetCell(13).SetCellValue(itemOver.ProjectControl_JobStatus); // if (overview.GetRow(rowIndex).GetCell(14) == null) overview.GetRow(rowIndex).CreateCell(14); // overview.GetRow(rowIndex).GetCell(14).SetCellValue(itemOver.Schedule); // if (overview.GetRow(rowIndex).GetCell(15) == null) overview.GetRow(rowIndex).CreateCell(15); // overview.GetRow(rowIndex).GetCell(15).SetCellValue(itemOver.Cost); // if (overview.GetRow(rowIndex).GetCell(16) == null) overview.GetRow(rowIndex).CreateCell(16); // overview.GetRow(rowIndex).GetCell(16).SetCellValue(itemOver.Scope); // if (overview.GetRow(rowIndex).GetCell(17) == null) overview.GetRow(rowIndex).CreateCell(17); // overview.GetRow(rowIndex).GetCell(17).SetCellValue(itemOver.PM_MA_JobReveive); // if (overview.GetRow(rowIndex).GetCell(18) == null) overview.GetRow(rowIndex).CreateCell(18); // overview.GetRow(rowIndex).GetCell(18).SetCellValue(itemOver.EstimatedFinalCost.HasValue ? string.Format("{0:N}",(float)itemOver.EstimatedFinalCost) :""); // if (overview.GetRow(rowIndex).GetCell(19) == null) overview.GetRow(rowIndex).CreateCell(19); // overview.GetRow(rowIndex).GetCell(19).SetCellValue(itemOver.MCActual); // if (overview.GetRow(rowIndex).GetCell(20) == null) overview.GetRow(rowIndex).CreateCell(20); // overview.GetRow(rowIndex).GetCell(20).SetCellValue(itemOver.MC_Signed); // if (overview.GetRow(rowIndex).GetCell(21) == null) overview.GetRow(rowIndex).CreateCell(21); // overview.GetRow(rowIndex).GetCell(21).SetCellValue(itemOver.FC_Signed); // if (overview.GetRow(rowIndex).GetCell(22) == null) overview.GetRow(rowIndex).CreateCell(22); // overview.GetRow(rowIndex).GetCell(22).SetCellValue(itemOver.ProjectControl_BC_CloseDate); // if (overview.GetRow(rowIndex).GetCell(23) == null) overview.GetRow(rowIndex).CreateCell(23); // overview.GetRow(rowIndex).GetCell(23).SetCellValue(itemOver.IFC_Received); // if (overview.GetRow(rowIndex).GetCell(24) == null) overview.GetRow(rowIndex).CreateCell(24); // overview.GetRow(rowIndex).GetCell(24).SetCellValue(itemOver.As_built_Received); // if (overview.GetRow(rowIndex).GetCell(25) == null) overview.GetRow(rowIndex).CreateCell(25); // overview.GetRow(rowIndex).GetCell(25).SetCellValue(itemOver.MD_Received); // if (overview.GetRow(rowIndex).GetCell(26) == null) overview.GetRow(rowIndex).CreateCell(26); // overview.GetRow(rowIndex).GetCell(26).SetCellValue(itemOver.ProjectControl_CostEffectvitity); // if (overview.GetRow(rowIndex).GetCell(27) == null) overview.GetRow(rowIndex).CreateCell(27); // overview.GetRow(rowIndex).GetCell(27).SetCellValue(itemOver.ProjectControl_PVIPrediction.HasValue ? Math.Round(Convert.ToDouble(itemOver.ProjectControl_PVIPrediction), 2) : 0); // if (overview.GetRow(rowIndex).GetCell(28) == null) overview.GetRow(rowIndex).CreateCell(28); // overview.GetRow(rowIndex).GetCell(28).SetCellValue(itemOver.ProjectControl_PC_CancelDate); // if (overview.GetRow(rowIndex).GetCell(29) == null) overview.GetRow(rowIndex).CreateCell(29); // overview.GetRow(rowIndex).GetCell(29).SetCellValue(itemOver.ProjectControl_NetworkNo); // if (overview.GetRow(rowIndex).GetCell(30) == null) overview.GetRow(rowIndex).CreateCell(30); // overview.GetRow(rowIndex).GetCell(30).SetCellValue(itemOver.PM_General_CDI); // #endregion // #region 填充背景色 // //超出计划MC6个月,仍未有实际MC日期(MC Actual) // if (!string.IsNullOrEmpty(itemOver.ProjectControl_MS_MC)) // { // if (Funs.GetNewDateTime(itemOver.ProjectControl_MS_MC).Value.AddMonths(6) < Funs.GetNewDateTime(DateTime.Now.ToShortDateString()) && string.IsNullOrEmpty(itemOver.MCActual)) // { // overview.GetRow(rowIndex).GetCell(20).CellStyle = redbackgroundstyle; // } // } // //超出实际MC10天,仍未签MC证书(MC Signed) // if (!string.IsNullOrEmpty(itemOver.MCActual)) // { // if (Funs.GetNewDateTime(itemOver.MCActual).Value.AddDays(10) < Funs.GetNewDateTime(DateTime.Now.ToShortDateString()) && string.IsNullOrEmpty(itemOver.MC_Signed)) // { // overview.GetRow(rowIndex).GetCell(21).CellStyle = redbackgroundstyle; // } // } // //超出实际MC90天,仍未签FC证书(FC Signed) // if (!string.IsNullOrEmpty(itemOver.MCActual)) // { // if (Funs.GetNewDateTime(itemOver.MCActual).Value.AddDays(90) < Funs.GetNewDateTime(DateTime.Now.ToShortDateString()) && string.IsNullOrEmpty(itemOver.FC_Signed)) // { // overview.GetRow(rowIndex).GetCell(22).CellStyle = redbackgroundstyle; // } // } // //超出FC180天,仍未商务关闭的(Business Closed) // if (!string.IsNullOrEmpty(itemOver.FC_Signed)) // { // if (Funs.GetNewDateTime(itemOver.FC_Signed).Value.AddDays(180) < Funs.GetNewDateTime(DateTime.Now.ToShortDateString()) && string.IsNullOrEmpty(itemOver.ProjectControl_BC_CloseDate)) // { // overview.GetRow(rowIndex).GetCell(23).CellStyle = redbackgroundstyle; // } // } // //超出实际MC90天,仍未收到AB的(As-built Received) // if (!string.IsNullOrEmpty(itemOver.MCActual)) // { // if (Funs.GetNewDateTime(itemOver.MCActual).Value.AddDays(90) < Funs.GetNewDateTime(DateTime.Now.ToShortDateString()) && string.IsNullOrEmpty(itemOver.As_built_Received)) // { // overview.GetRow(rowIndex).GetCell(25).CellStyle = redbackgroundstyle; // } // } // #endregion // rowIndex++; // } //} //#endregion //#region Permit_General //XSSFSheet pg = (XSSFSheet)hssfworkbook.GetSheet("Permit_General"); //var Permit_General = (from x in Funs.DB.View_Report_PermitGeneral orderby x.ProjectControl_JobNo descending select x).ToList(); //if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) //{ // Permit_General = Permit_General.Where(x => x.ProjectControl_JobNo.Contains(this.txtJobNo.Text.Trim())).ToList(); //} //if (Permit_General.Count > 0) //{ // var rowIndex = 1; // foreach (var item in Permit_General) // { // if (pg.GetRow(rowIndex) == null) pg.CreateRow(rowIndex); // #region 列赋值 // if (item.PType == "计划") // { // if (pg.GetRow(rowIndex).GetCell(0) == null) pg.GetRow(rowIndex).CreateCell(0); // pg.GetRow(rowIndex).GetCell(0).SetCellValue(item.ProjectControl_JobNo); // pg.GetRow(rowIndex).GetCell(0).CellStyle.SetFont(cs_content_Fonts);//将字体绑定到样式 // if (pg.GetRow(rowIndex).GetCell(1) == null) pg.GetRow(rowIndex).CreateCell(1); // pg.GetRow(rowIndex).GetCell(1).SetCellValue(item.ProjectControl_JobTitle); // pg.GetRow(rowIndex).GetCell(1).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(2) == null) pg.GetRow(rowIndex).CreateCell(2); // pg.GetRow(rowIndex).GetCell(2).SetCellValue(item.ProjectControl_ProjectManager); // pg.GetRow(rowIndex).GetCell(2).CellStyle.SetFont(cs_content_Fonts); // } // if (pg.GetRow(rowIndex).GetCell(3) == null) pg.GetRow(rowIndex).CreateCell(3); // pg.GetRow(rowIndex).GetCell(3).SetCellValue(item.PType); // pg.GetRow(rowIndex).GetCell(3).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(4) == null) pg.GetRow(rowIndex).CreateCell(4); // pg.GetRow(rowIndex).GetCell(4).SetCellValue(item.EnvAssess); // pg.GetRow(rowIndex).GetCell(4).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(5) == null) pg.GetRow(rowIndex).CreateCell(5); // pg.GetRow(rowIndex).GetCell(5).SetCellValue(item.EnergySaving); // pg.GetRow(rowIndex).GetCell(5).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(6) == null) pg.GetRow(rowIndex).CreateCell(6); // pg.GetRow(rowIndex).GetCell(6).SetCellValue(item.ProjectRegistr); // pg.GetRow(rowIndex).GetCell(6).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(7) == null) pg.GetRow(rowIndex).CreateCell(7); // pg.GetRow(rowIndex).GetCell(7).SetCellValue(item.PlanningPermit); // pg.GetRow(rowIndex).GetCell(7).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(8) == null) pg.GetRow(rowIndex).CreateCell(8); // pg.GetRow(rowIndex).GetCell(8).SetCellValue(item.SafetyConReview); // pg.GetRow(rowIndex).GetCell(8).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(9) == null) pg.GetRow(rowIndex).CreateCell(9); // pg.GetRow(rowIndex).GetCell(9).SetCellValue(item.SafetyDesginReview); // pg.GetRow(rowIndex).GetCell(9).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(10) == null) pg.GetRow(rowIndex).CreateCell(10); // pg.GetRow(rowIndex).GetCell(10).SetCellValue(item.FFDesginReview); // pg.GetRow(rowIndex).GetCell(10).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(11) == null) pg.GetRow(rowIndex).CreateCell(11); // pg.GetRow(rowIndex).GetCell(11).SetCellValue(item.ConstPermit); // pg.GetRow(rowIndex).GetCell(11).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(12) == null) pg.GetRow(rowIndex).CreateCell(12); // pg.GetRow(rowIndex).GetCell(12).SetCellValue(item.CMStart); // pg.GetRow(rowIndex).GetCell(12).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(13) == null) pg.GetRow(rowIndex).CreateCell(13); // pg.GetRow(rowIndex).GetCell(13).SetCellValue(item.MC); // pg.GetRow(rowIndex).GetCell(13).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(14) == null) pg.GetRow(rowIndex).CreateCell(14); // pg.GetRow(rowIndex).GetCell(14).SetCellValue(item.SafetyFinalAcc); // pg.GetRow(rowIndex).GetCell(14).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(15) == null) pg.GetRow(rowIndex).CreateCell(15); // pg.GetRow(rowIndex).GetCell(15).SetCellValue(item.FFFinalAcc); // pg.GetRow(rowIndex).GetCell(15).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(16) == null) pg.GetRow(rowIndex).CreateCell(16); // pg.GetRow(rowIndex).GetCell(16).SetCellValue(item.Usin); // pg.GetRow(rowIndex).GetCell(16).CellStyle.SetFont(cs_content_Fonts); // if (pg.GetRow(rowIndex).GetCell(17) == null) pg.GetRow(rowIndex).CreateCell(17); // pg.GetRow(rowIndex).GetCell(17).SetCellValue(item.EnvFinalAcc); // pg.GetRow(rowIndex).GetCell(17).CellStyle.SetFont(cs_content_Fonts); // #endregion // #region 填充背景色 // if (item.PType == "计划") // { // #region 设置计划行背景色 // pg.GetRow(rowIndex).GetCell(0).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(1).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(2).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(3).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(9).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(10).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(11).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(12).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(13).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(14).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(15).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(16).CellStyle = backgroundstyle1; // pg.GetRow(rowIndex).GetCell(17).CellStyle = backgroundstyle1; // #endregion // #region 如果距计划日期还有超过一个月的时间,则计划日期显示黄底黑字 // if (item.EnvAssess != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.EnvAssess))//环评 // { // pg.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle1; // } // if (item.EnergySaving != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.EnergySaving))//节能报告 // { // pg.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle1; // } // if (item.ProjectRegistr != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.ProjectRegistr))//项目备案 // { // pg.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle1; // } // if (item.PlanningPermit != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.PlanningPermit))//规划许可 // { // pg.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle1; // } // if (item.SafetyConReview != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.SafetyConReview))//安全条件审查 // { // pg.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle1; // } // if (item.SafetyDesginReview != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.SafetyDesginReview))//安全设施设计审查 // { // pg.GetRow(rowIndex).GetCell(9).CellStyle = backgroundstyle1; // } // if (item.FFDesginReview != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.FFDesginReview))//消防设计审查 // { // pg.GetRow(rowIndex).GetCell(10).CellStyle = backgroundstyle1; // } // if (item.ConstPermit != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.ConstPermit))//施工许可 // { // pg.GetRow(rowIndex).GetCell(11).CellStyle = backgroundstyle1; // } // //if (item.CMStart != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.CMStart))//施工开始 // //{ // // pg.GetRow(rowIndex).GetCell(12).CellStyle = backgroundstyle1; // //} // //if (item.MC != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.MC))//机械竣工 // //{ // // pg.GetRow(rowIndex).GetCell(13).CellStyle = backgroundstyle1; // //} // if (item.SafetyFinalAcc != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.SafetyFinalAcc))//安全设施竣工验收 // { // pg.GetRow(rowIndex).GetCell(14).CellStyle = backgroundstyle1; // } // if (item.FFFinalAcc != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.FFFinalAcc))//消防设施竣工验收 // { // pg.GetRow(rowIndex).GetCell(15).CellStyle = backgroundstyle1; // } // //if (item.Usin != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.Usin))//投用 // //{ // // pg.GetRow(rowIndex).GetCell(16).CellStyle = backgroundstyle1; // //} // if (item.EnvFinalAcc != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.EnvFinalAcc))//环保设施竣工验收 // { // pg.GetRow(rowIndex).GetCell(17).CellStyle = backgroundstyle1; // } // #endregion // #region 如果下月须完成,则显示黄底红字 // if (item.EnvAssess != "-" && DateTime.Now.Year == Convert.ToDateTime(item.EnvAssess).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.EnvAssess).Month) // { // pg.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle2;//环评 // } // if (item.EnergySaving != "-" && DateTime.Now.Year == Convert.ToDateTime(item.EnergySaving).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.EnergySaving).Month) // { // pg.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle2;//节能报告 // } // if (item.ProjectRegistr != "-" && DateTime.Now.Year == Convert.ToDateTime(item.ProjectRegistr).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.ProjectRegistr).Month) // { // pg.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle2;//项目备案 // } // if (item.PlanningPermit != "-" && DateTime.Now.Year == Convert.ToDateTime(item.PlanningPermit).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.PlanningPermit).Month) // { // pg.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle2;//规划许可 // } // if (item.SafetyConReview != "-" && DateTime.Now.Year == Convert.ToDateTime(item.SafetyConReview).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.SafetyConReview).Month) // { // pg.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle2;//安全条件审查 // } // if (item.SafetyDesginReview != "-" && DateTime.Now.Year == Convert.ToDateTime(item.SafetyDesginReview).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.SafetyDesginReview).Month) // { // pg.GetRow(rowIndex).GetCell(9).CellStyle = backgroundstyle2;//安全设施设计审查 // } // if (item.FFDesginReview != "-" && DateTime.Now.Year == Convert.ToDateTime(item.FFDesginReview).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.FFDesginReview).Month) // { // pg.GetRow(rowIndex).GetCell(10).CellStyle = backgroundstyle2;//消防设计审查 // } // if (item.ConstPermit != "-" && DateTime.Now.Year == Convert.ToDateTime(item.ConstPermit).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.ConstPermit).Month) // { // pg.GetRow(rowIndex).GetCell(11).CellStyle = backgroundstyle2;//施工许可 // } // //if (item.CMStart != "-" && DateTime.Now.Year == Convert.ToDateTime(item.CMStart).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.CMStart).Month) // //{ // // pg.GetRow(rowIndex).GetCell(12).CellStyle = backgroundstyle2;//施工开始 // //} // //if (item.MC != "-" && DateTime.Now.Year == Convert.ToDateTime(item.MC).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.MC).Month) // //{ // // pg.GetRow(rowIndex).GetCell(13).CellStyle = backgroundstyle2;//机械竣工 // //} // if (item.SafetyFinalAcc != "-" && DateTime.Now.Year == Convert.ToDateTime(item.SafetyFinalAcc).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.SafetyFinalAcc).Month) // { // pg.GetRow(rowIndex).GetCell(14).CellStyle = backgroundstyle2;//安全设施竣工验收 // } // if (item.FFFinalAcc != "-" && DateTime.Now.Year == Convert.ToDateTime(item.FFFinalAcc).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.FFFinalAcc).Month) // { // pg.GetRow(rowIndex).GetCell(15).CellStyle = backgroundstyle2;//消防设施竣工验收 // } // //if (item.Usin != "-" && DateTime.Now.Year == Convert.ToDateTime(item.Usin).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.Usin).Month) // //{ // // pg.GetRow(rowIndex).GetCell(16).CellStyle = backgroundstyle2;//投用 // //} // if (item.EnvFinalAcc != "-" && DateTime.Now.Year == Convert.ToDateTime(item.EnvFinalAcc).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.EnvFinalAcc).Month) // { // pg.GetRow(rowIndex).GetCell(17).CellStyle = backgroundstyle2;//环保设施竣工验收 // } // #endregion // #region 如果已过计划日期一个月,但还未完成,则显示红底红字 // var actual = (from x in Funs.DB.View_Report_PermitGeneral where x.ProjectControl_JobNo == item.ProjectControl_JobNo && x.PType == "实际" select x).FirstOrDefault(); // if (actual != null) // { // if (item.EnvAssess != "-" && Convert.ToDateTime(item.EnvAssess).AddMonths(1) < DateTime.Now)//环评 // { // if (actual.EnvAssess == "-") // { // pg.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle3; // } // } // if (item.EnergySaving != "-" && Convert.ToDateTime(item.EnergySaving).AddMonths(1) < DateTime.Now)//节能报告 // { // if (actual.EnergySaving == "-") // { // pg.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle3; // } // } // if (item.ProjectRegistr != "-" && Convert.ToDateTime(item.ProjectRegistr).AddMonths(1) < DateTime.Now)//项目备案 // { // if (actual.ProjectRegistr == "-") // { // pg.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle3; // } // } // if (item.PlanningPermit != "-" && Convert.ToDateTime(item.PlanningPermit).AddMonths(1) < DateTime.Now)//规划许可 // { // if (actual.PlanningPermit == "-") // { // pg.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle3; // } // } // if (item.SafetyConReview != "-" && Convert.ToDateTime(item.SafetyConReview).AddMonths(1) < DateTime.Now)//安全条件审查 // { // if (actual.SafetyConReview == "-") // { // pg.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle3; // } // } // if (item.SafetyDesginReview != "-" && Convert.ToDateTime(item.SafetyDesginReview).AddMonths(1) < DateTime.Now)//安全设施设计审查 // { // if (actual.SafetyDesginReview == "-") // { // pg.GetRow(rowIndex).GetCell(9).CellStyle = backgroundstyle3; // } // } // if (item.FFDesginReview != "-" && Convert.ToDateTime(item.FFDesginReview).AddMonths(1) < DateTime.Now)//消防设计审查 // { // if (actual.FFDesginReview == "-") // { // pg.GetRow(rowIndex).GetCell(10).CellStyle = backgroundstyle3; // } // } // if (item.ConstPermit != "-" && Convert.ToDateTime(item.ConstPermit).AddMonths(1) < DateTime.Now)//施工许可 // { // if (actual.ConstPermit == "-") // { // pg.GetRow(rowIndex).GetCell(11).CellStyle = backgroundstyle3; // } // } // //if (item.CMStart != "-" && Convert.ToDateTime(item.CMStart).AddMonths(1) < DateTime.Now )//施工开始 // //{ // // if (actual.CMStart == "-") // // { // // pg.GetRow(rowIndex).GetCell(12).CellStyle = backgroundstyle3; // // } // //} // //if (item.MC != "-" && Convert.ToDateTime(item.MC).AddMonths(1) < DateTime.Now )//机械竣工 // //{ // // if (actual.MC == "-") // // { // // pg.GetRow(rowIndex).GetCell(13).CellStyle = backgroundstyle3; // // } // //} // if (item.SafetyFinalAcc != "-" && Convert.ToDateTime(item.SafetyFinalAcc).AddMonths(1) < DateTime.Now)//安全设施竣工验收 // { // if (actual.SafetyFinalAcc == "-") // { // pg.GetRow(rowIndex).GetCell(14).CellStyle = backgroundstyle3; // } // } // if (item.FFFinalAcc != "-" && Convert.ToDateTime(item.FFFinalAcc).AddMonths(1) < DateTime.Now)//消防设施竣工验收 // { // if (actual.FFFinalAcc == "-") // { // pg.GetRow(rowIndex).GetCell(15).CellStyle = backgroundstyle3; // } // } // //if (item.Usin != "-" && Convert.ToDateTime(item.Usin).AddMonths(1) < DateTime.Now)//投用 // //{ // // if (actual.Usin == "-") // // { // // pg.GetRow(rowIndex).GetCell(16).CellStyle = backgroundstyle3; // // } // //} // if (item.EnvFinalAcc != "-" && Convert.ToDateTime(item.EnvFinalAcc).AddMonths(1) < DateTime.Now)//环保设施竣工验收 // { // if (actual.EnvFinalAcc == "-") // { // pg.GetRow(rowIndex).GetCell(17).CellStyle = backgroundstyle3; // } // } // } // #endregion // #region 一旦实际日期栏填入数据,则计划日期恢复成黄底黑字 // var eproject = BLL.EProjectService.GeteProjectByJobNO(item.ProjectControl_JobNo); // if (eproject != null) // { // if (eproject.Permit_PPA_EnvAssess.HasValue && item.EnvAssess != "-") // { // pg.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle1;//环评 // } // if (eproject.Permit_PPA_EnergySaving.HasValue && item.EnergySaving != "-") // { // pg.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle1;//节能报告 // } // if (eproject.Permit_PPA_ProjectRegistration.HasValue && item.ProjectRegistr != "-") // { // pg.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle1;//项目备案 // } // if (eproject.Permit_PPA_PlanningPermit.HasValue && item.PlanningPermit != "-") // { // pg.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle1;//规划许可 // } // if (eproject.Permit_PPA_SafetyConRev.HasValue && item.SafetyConReview != "-") // { // pg.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle1;//安全条件审查 // } // if (eproject.Permit_PPA_SafetyDesignRev.HasValue && item.SafetyDesginReview != "-") // { // pg.GetRow(rowIndex).GetCell(9).CellStyle = backgroundstyle1;//安全设施设计审查 // } // if (eproject.Permit_PPA_FFDesignReview.HasValue && item.FFDesginReview != "-") // { // pg.GetRow(rowIndex).GetCell(10).CellStyle = backgroundstyle1;//消防设计审查 // } // if (eproject.Permit_PA_ConstPermit.HasValue && item.ConstPermit != "-") // { // pg.GetRow(rowIndex).GetCell(11).CellStyle = backgroundstyle1;//施工许可 // } // //if (eproject.Permit_PA_ConstPermit.HasValue&&item.CMStart!="-") // //{ // // pg.GetRow(rowIndex).GetCell(12).CellStyle = backgroundstyle1;//施工开始 // //} // //if (eproject.CM_MA_MC.HasValue && item.MC != "-") // //{ // // pg.GetRow(rowIndex).GetCell(13).CellStyle = backgroundstyle1;//机械竣工 // //} // if (eproject.Permit_PA_SafetyFinalACC.HasValue && item.SafetyFinalAcc != "-") // { // pg.GetRow(rowIndex).GetCell(14).CellStyle = backgroundstyle1;//安全设施竣工验收 // } // if (eproject.Permit_PA_FFFinalACC.HasValue && item.FFFinalAcc != "-") // { // pg.GetRow(rowIndex).GetCell(15).CellStyle = backgroundstyle1;//消防设施竣工验收 // } // //if (eproject.CM_MA_MC.HasValue && item.Usin != "-") // //{ // // pg.GetRow(rowIndex).GetCell(16).CellStyle = backgroundstyle1;//投用 // //} // if (eproject.Permit_PA_EnvFinalACC.HasValue && item.EnvFinalAcc != "-") // { // pg.GetRow(rowIndex).GetCell(17).CellStyle = backgroundstyle1;//环保设施竣工验收 // } // } // #endregion // } // if (item.PType == "实际") // { // var plan = (from x in Funs.DB.View_Report_PermitGeneral where x.ProjectControl_JobNo == item.ProjectControl_JobNo && x.PType == "计划" select x).FirstOrDefault(); // if (plan != null) // { // //如果提前或按时完成,则显示白底黑字 // //if (!string.IsNullOrEmpty(item.EnvAssess) && !string.IsNullOrEmpty(plan.EnvAssess) && item.EnvAssess != "-" && plan.EnvAssess != "-" && Convert.ToDateTime(item.EnvAssess) <= Convert.ToDateTime(plan.EnvAssess)) // //{ // //} // #region 如果是在计划日期后完成,则显示白底红字 // if (plan.EnvAssess != "-" && item.EnvAssess != "-" && Convert.ToDateTime(plan.EnvAssess) < Convert.ToDateTime(item.EnvAssess)) // { // pg.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle4;//环评 // } // if (plan.EnergySaving != "-" && item.EnergySaving != "-" && Convert.ToDateTime(plan.EnergySaving) < Convert.ToDateTime(item.EnergySaving)) // { // pg.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle4;//节能报告 // } // if (plan.ProjectRegistr != "-" && item.ProjectRegistr != "-" && Convert.ToDateTime(plan.ProjectRegistr) < Convert.ToDateTime(item.ProjectRegistr)) // { // pg.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle4;//项目备案 // } // if (plan.PlanningPermit != "-" && item.PlanningPermit != "-" && Convert.ToDateTime(plan.PlanningPermit) < Convert.ToDateTime(item.PlanningPermit)) // { // pg.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle4;//规划许可 // } // if (plan.SafetyConReview != "-" && item.SafetyConReview != "-" && Convert.ToDateTime(plan.SafetyConReview) < Convert.ToDateTime(item.SafetyConReview)) // { // pg.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle4;//安全条件审查 // } // if (plan.SafetyDesginReview != "-" && item.SafetyDesginReview != "-" && Convert.ToDateTime(plan.SafetyDesginReview) < Convert.ToDateTime(item.SafetyDesginReview)) // { // pg.GetRow(rowIndex).GetCell(9).CellStyle = backgroundstyle4;//安全设施设计审查 // } // if (plan.FFDesginReview != "-" && item.FFDesginReview != "-" && Convert.ToDateTime(plan.FFDesginReview) < Convert.ToDateTime(item.FFDesginReview)) // { // pg.GetRow(rowIndex).GetCell(10).CellStyle = backgroundstyle4;//消防设计审查 // } // if (plan.ConstPermit != "-" && item.ConstPermit != "-" && Convert.ToDateTime(plan.ConstPermit) < Convert.ToDateTime(item.ConstPermit)) // { // pg.GetRow(rowIndex).GetCell(11).CellStyle = backgroundstyle4;//施工许可 // } // //if (plan.CMStart != "-" && item.CMStart != "-" && Convert.ToDateTime(plan.CMStart) < Convert.ToDateTime(item.CMStart)) // //{ // // pg.GetRow(rowIndex).GetCell(12).CellStyle = backgroundstyle4;//施工开始 // //} // //if (plan.MC != "-" && item.MC != "-" && Convert.ToDateTime(plan.MC) < Convert.ToDateTime(item.MC)) // //{ // // pg.GetRow(rowIndex).GetCell(13).CellStyle = backgroundstyle4;//机械竣工 // //} // if (plan.SafetyFinalAcc != "-" && item.SafetyFinalAcc != "-" && Convert.ToDateTime(plan.SafetyFinalAcc) < Convert.ToDateTime(item.SafetyFinalAcc)) // { // pg.GetRow(rowIndex).GetCell(14).CellStyle = backgroundstyle4;//安全设施竣工验收 // } // if (plan.FFFinalAcc != "-" && item.FFFinalAcc != "-" && Convert.ToDateTime(plan.FFFinalAcc) < Convert.ToDateTime(item.FFFinalAcc)) // { // pg.GetRow(rowIndex).GetCell(15).CellStyle = backgroundstyle4;//消防设施竣工验收 // } // //if (plan.Usin != "-" && item.Usin != "-" && Convert.ToDateTime(plan.Usin) < Convert.ToDateTime(item.Usin)) // //{ // // pg.GetRow(rowIndex).GetCell(16).CellStyle = backgroundstyle4;//投用 // //} // if (plan.EnvFinalAcc != "-" && item.EnvFinalAcc != "-" && Convert.ToDateTime(plan.EnvFinalAcc) < Convert.ToDateTime(item.EnvFinalAcc)) // { // pg.GetRow(rowIndex).GetCell(17).CellStyle = backgroundstyle4;//环保设施竣工验收 // } // #endregion // } // } // #endregion // rowIndex++; // } //} //#endregion //#region Permit_Pressure Piping & Vesse //XSSFSheet ppv = (XSSFSheet)hssfworkbook.GetSheet("Permit_Pressure Piping & Vesse"); //var PressurePipingVesseReport = (from x in Funs.DB.View_Report_Permit_PressurePipingVesse orderby x.ProjectControl_JobNo descending select x).ToList(); //if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) //{ // PressurePipingVesseReport = PressurePipingVesseReport.Where(x => x.ProjectControl_JobNo.Contains(this.txtJobNo.Text.Trim())).ToList(); //} //if (PressurePipingVesseReport.Count > 0) //{ // var rowIndex = 1; // foreach (var item in PressurePipingVesseReport) // { // if (ppv.GetRow(rowIndex) == null) ppv.CreateRow(rowIndex); // #region 列赋值 // if (item.PType == "计划") // { // if (ppv.GetRow(rowIndex).GetCell(0) == null) ppv.GetRow(rowIndex).CreateCell(0); // ppv.GetRow(rowIndex).GetCell(0).SetCellValue(item.ProjectControl_JobNo); // ppv.GetRow(rowIndex).GetCell(0).CellStyle.SetFont(cs_content_Fonts);//将字体绑定到样式 // if (ppv.GetRow(rowIndex).GetCell(1) == null) ppv.GetRow(rowIndex).CreateCell(1); // ppv.GetRow(rowIndex).GetCell(1).SetCellValue(item.ProjectControl_JobTitle); // ppv.GetRow(rowIndex).GetCell(1).CellStyle.SetFont(cs_content_Fonts); // if (ppv.GetRow(rowIndex).GetCell(2) == null) ppv.GetRow(rowIndex).CreateCell(2); // ppv.GetRow(rowIndex).GetCell(2).SetCellValue(item.ProjectControl_ProjectManager); // ppv.GetRow(rowIndex).GetCell(2).CellStyle.SetFont(cs_content_Fonts); // } // if (ppv.GetRow(rowIndex).GetCell(3) == null) ppv.GetRow(rowIndex).CreateCell(3); // ppv.GetRow(rowIndex).GetCell(3).SetCellValue(item.PType); // ppv.GetRow(rowIndex).GetCell(3).CellStyle.SetFont(cs_content_Fonts); // if (ppv.GetRow(rowIndex).GetCell(4) == null) ppv.GetRow(rowIndex).CreateCell(4); // ppv.GetRow(rowIndex).GetCell(4).SetCellValue(item.PressurePiping); // ppv.GetRow(rowIndex).GetCell(4).CellStyle.SetFont(cs_content_Fonts); // if (ppv.GetRow(rowIndex).GetCell(5) == null) ppv.GetRow(rowIndex).CreateCell(5); // ppv.GetRow(rowIndex).GetCell(5).SetCellValue(item.PressureVessel); // ppv.GetRow(rowIndex).GetCell(5).CellStyle.SetFont(cs_content_Fonts); // if (ppv.GetRow(rowIndex).GetCell(6) == null) ppv.GetRow(rowIndex).CreateCell(6); // ppv.GetRow(rowIndex).GetCell(6).SetCellValue(item.SQIB); // ppv.GetRow(rowIndex).GetCell(6).CellStyle.SetFont(cs_content_Fonts); // if (ppv.GetRow(rowIndex).GetCell(7) == null) ppv.GetRow(rowIndex).CreateCell(7); // ppv.GetRow(rowIndex).GetCell(7).SetCellValue(item.ArchiveAccep); // ppv.GetRow(rowIndex).GetCell(7).CellStyle.SetFont(cs_content_Fonts); // if (ppv.GetRow(rowIndex).GetCell(8) == null) ppv.GetRow(rowIndex).CreateCell(8); // ppv.GetRow(rowIndex).GetCell(8).SetCellValue(item.ThrdConstJian); // ppv.GetRow(rowIndex).GetCell(8).CellStyle.SetFont(cs_content_Fonts); // #endregion // #region 填充背景色 // if (item.PType == "计划") // { // #region 设置计划行背景色 // ppv.GetRow(rowIndex).GetCell(0).CellStyle = backgroundstyle1; // ppv.GetRow(rowIndex).GetCell(1).CellStyle = backgroundstyle1; // ppv.GetRow(rowIndex).GetCell(2).CellStyle = backgroundstyle1; // ppv.GetRow(rowIndex).GetCell(3).CellStyle = backgroundstyle1; // ppv.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle1; // ppv.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle1; // ppv.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle1; // ppv.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle1; // ppv.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle1; // #endregion // #region 如果距计划日期还有超过一个月的时间,则计划日期显示黄底黑字 // if (item.PressurePiping != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.PressurePiping))//压力管道 // { // ppv.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle1; // } // if (item.PressureVessel != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.PressureVessel))//压力容器 // { // ppv.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle1; // } // #endregion // #region 如果下月须完成,则显示黄底红字 // if (item.PressurePiping != "-" && DateTime.Now.Year == Convert.ToDateTime(item.PressurePiping).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.PressurePiping).Month) // { // ppv.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle2;//压力管道 // } // if (item.PressureVessel != "-" && DateTime.Now.Year == Convert.ToDateTime(item.PressureVessel).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.PressureVessel).Month) // { // ppv.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle2;//压力容器 // } // #endregion // #region 如果已过计划日期一个月,但还未完成,则显示红底红字 // var actual = (from x in Funs.DB.View_Report_Permit_PressurePipingVesse where x.ProjectControl_JobNo == item.ProjectControl_JobNo && x.PType == "实际" select x).FirstOrDefault(); // if (actual != null) // { // if (item.PressurePiping != "-" && Convert.ToDateTime(item.PressurePiping).AddMonths(1) < DateTime.Now)//压力管道 // { // if (actual.PressurePiping == "-") // { // ppv.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle3; // } // } // if (item.PressureVessel != "-" && Convert.ToDateTime(item.PressureVessel).AddMonths(1) < DateTime.Now)//压力容器 // { // if (actual.PressureVessel == "-") // { // ppv.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle3; // } // } // } // #endregion // #region 一旦实际日期栏填入数据,则计划日期恢复成黄底黑字 // var eproject = BLL.EProjectService.GeteProjectByJobNO(item.ProjectControl_JobNo); // if (eproject != null) // { // if (eproject.SQIB_PressurePiping.HasValue && item.PressurePiping != "-") // { // ppv.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle1;//压力管道 // } // if (eproject.SQIB_PressureVessel.HasValue && item.PressureVessel != "-") // { // ppv.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle1;//压力容器 // } // } // #endregion // } // if (item.PType == "实际") // { // var plan = (from x in Funs.DB.View_Report_Permit_PressurePipingVesse where x.ProjectControl_JobNo == item.ProjectControl_JobNo && x.PType == "计划" select x).FirstOrDefault(); // if (plan != null) // { // //如果提前或按时完成,则显示白底黑字 // //if (!string.IsNullOrEmpty(item.EnvAssess) && !string.IsNullOrEmpty(plan.EnvAssess) && item.EnvAssess != "-" && plan.EnvAssess != "-" && Convert.ToDateTime(item.EnvAssess) <= Convert.ToDateTime(plan.EnvAssess)) // //{ // //} // #region 如果是在计划日期后完成,则显示白底红字 // if (plan.PressurePiping != "-" && item.PressurePiping != "-" && Convert.ToDateTime(plan.PressurePiping) < Convert.ToDateTime(item.PressurePiping)) // { // ppv.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle4;//压力管道 // } // if (plan.PressureVessel != "-" && item.PressureVessel != "-" && Convert.ToDateTime(plan.PressureVessel) < Convert.ToDateTime(item.PressureVessel)) // { // ppv.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle4;//压力容器 // } // #endregion // } // } // #endregion // rowIndex++; // } //} //#endregion //#region Schedule_Gantt_Bar //XSSFSheet sgb = (XSSFSheet)hssfworkbook.GetSheet("Schedule_Gantt_Bar"); //string strSql = @"SELECT * FROM View_Report_ScheduleGanttBar WHERE 1=1 "; //List listStr = new List(); //if (!string.IsNullOrEmpty(this.txtJobNo.Text.Trim())) //{ // strSql += " AND ProjectControl_JobNo LIKE @JobNO "; // listStr.Add(new SqlParameter("@JobNO", "%" + this.txtJobNo.Text.Trim() + "%")); //} //strSql += " order by ProjectControl_JobNo desc"; //SqlParameter[] parameter = listStr.ToArray(); //DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); //GregorianCalendar gc = new GregorianCalendar(); //for (int i = -3; i < 2; i++) //{ // DateTime dateTime = new DateTime(DateTime.Now.Year + i, 12, 31); // for (int j = 1; j <= gc.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday); j++) // { // tb.Columns.Add(dateTime.Year + "-" + j, System.Type.GetType("System.String")); // } //} //for (int i = 0; i < tb.Rows.Count; i++) //{ // try // { // var ReceiveDate = tb.Rows[i]["ReceiveDate"]; // var ApprovalDate = tb.Rows[i]["ApprovalDate"]; // var ConstStart = tb.Rows[i]["ConstMECivilStart"]; // var DEMEEnd = tb.Rows[i]["DEMECivilEnd"]; // var ConstEnd = tb.Rows[i]["ConstMECivilEnd"]; // if (ReceiveDate is DateTime && ApprovalDate is DateTime) // { // DateTime start = (DateTime)ReceiveDate; // DateTime end = (DateTime)ApprovalDate; // for (; start < end; start = start.AddDays(7)) // { // if (tb.Columns.Contains(start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday))) // tb.Rows[i][start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday)] = "A"; // } // } // if (ApprovalDate is DateTime && ConstStart is DateTime) // { // DateTime start = (DateTime)ApprovalDate; // DateTime end = (DateTime)ConstStart; // for (; start < end; start = start.AddDays(7)) // { // if (tb.Columns.Contains(start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday))) // tb.Rows[i][start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday)] = "B"; // } // } // if (ConstStart is DateTime && DEMEEnd is DateTime) // { // DateTime start = (DateTime)ConstStart; // DateTime end = (DateTime)DEMEEnd; // for (; start < end; start = start.AddDays(7)) // { // if (tb.Columns.Contains(start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday))) // tb.Rows[i][start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday)] = "C"; // } // } // if (DEMEEnd is DateTime && ConstEnd is DateTime) // { // DateTime start = (DateTime)DEMEEnd; // DateTime end = (DateTime)ConstEnd; // for (; start < end; start = start.AddDays(7)) // { // if (tb.Columns.Contains(start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday))) // tb.Rows[i][start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday)] = "D"; // } // } // } // catch (Exception e1) // { // } //} ////计算excel表头 //int index = 1; //XSSFFont cs_content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 //cs_content_Font.FontName = "Arial";//字体 //cs_content_Font.FontHeightInPoints = 10; //字体大小 //ICellStyle styleToday = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 //styleToday.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Pink.Index; //styleToday.FillPattern = FillPattern.SolidForeground; //for (int i = -3; i < 2; i++) //{ // DateTime dateTime = new DateTime(DateTime.Now.Year + i, 12, 31); // ICellStyle styleTitle = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 // switch (i) // { // case -3: // styleTitle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.CornflowerBlue.Index; // break; // case -2: // styleTitle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightYellow.Index; // break; // case -1: // styleTitle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Rose.Index; // break; // case 0: // styleTitle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Green.Index; // break; // case 1: // styleTitle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.SkyBlue.Index; // break; // } // styleTitle.FillPattern = FillPattern.SolidForeground; // for (int j = 1; j <= gc.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday); j++) // { // byte[] rgb = new byte[3] { 192, 0, 0 }; // sgb.GetRow(0).CreateCell(index + 6); // sgb.GetRow(1).CreateCell(index + 6).SetCellValue(j); // sgb.GetRow(0).GetCell(index + 6).CellStyle = styleTitle; // if (dateTime.Year == DateTime.Now.Year && gc.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Monday) == j) // { // sgb.GetRow(1).GetCell(index + 6).CellStyle = styleToday; // sgb.GetRow(1).GetCell(index + 6).CellStyle.VerticalAlignment = VerticalAlignment.Bottom; // } // else // { // sgb.GetRow(1).GetCell(index + 6).CellStyle = styleTitle; // sgb.GetRow(1).GetCell(index + 6).CellStyle.VerticalAlignment = VerticalAlignment.Center; // } // sgb.GetRow(1).GetCell(index + 6).CellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; // sgb.GetRow(1).GetCell(index + 6).CellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; // sgb.GetRow(1).GetCell(index + 6).CellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; // sgb.GetRow(1).GetCell(index + 6).CellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; // //sgb.GetRow(0).GetCell(index + 6).CellStyle.SetFont(cs_content_Font);//将字体绑定到样式 // //sgb.GetRow(1).GetCell(index + 6).CellStyle.SetFont(cs_content_Font);//将字体绑定到样式 // index++; // } // CellRangeAddress cellRangeAddress = new CellRangeAddress(0, 0, index + 6 - gc.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday), (index + 5)); // sgb.AddMergedRegion(cellRangeAddress); // sgb.GetRow(0).GetCell(index + 6 - gc.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday)).SetCellValue(dateTime.Year); // sgb.GetRow(0).GetCell(index + 6 - gc.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday)).CellStyle.Alignment = HorizontalAlignment.Center; //} //ICellStyle style = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 //style.FillPattern = FillPattern.SolidForeground; //ICellStyle styleA = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 //styleA.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index; //styleA.FillPattern = FillPattern.SolidForeground; //ICellStyle styleB = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 //styleB.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightBlue.Index; //styleB.FillPattern = FillPattern.SolidForeground; //ICellStyle styleC = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 //styleC.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Indigo.Index; //styleC.FillPattern = FillPattern.SolidForeground; //ICellStyle styleD = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 //styleD.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightBlue.Index; //styleD.FillPattern = FillPattern.SolidForeground; //if (tb.Rows.Count > 0) //{ // var rowIndex = 2; // for (int i = 0; i < tb.Rows.Count; i++) // { // if (sgb.GetRow(rowIndex) == null) sgb.CreateRow(rowIndex); // //XSSFFont cs_content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 // //cs_content_Font.FontHeightInPoints = 10; //字体大小 // #region 列赋值 // if (sgb.GetRow(rowIndex).GetCell(0) == null) sgb.GetRow(rowIndex).CreateCell(0); // sgb.GetRow(rowIndex).GetCell(0).SetCellValue(tb.Rows[i]["ProjectControl_JobNo"].ToString()); // //sgb.GetRow(rowIndex).GetCell(0).CellStyle.SetFont(cs_content_Font);//将字体绑定到样式 // if (sgb.GetRow(rowIndex).GetCell(1) == null) sgb.GetRow(rowIndex).CreateCell(1); // sgb.GetRow(rowIndex).GetCell(1).SetCellValue(tb.Rows[i]["ProjectControl_BUCode"].ToString()); // if (sgb.GetRow(rowIndex).GetCell(2) == null) sgb.GetRow(rowIndex).CreateCell(2); // sgb.GetRow(rowIndex).GetCell(2).SetCellValue(tb.Rows[i]["ProjectControl_JobType"].ToString()); // if (sgb.GetRow(rowIndex).GetCell(3) == null) sgb.GetRow(rowIndex).CreateCell(3); // sgb.GetRow(rowIndex).GetCell(3).SetCellValue(tb.Rows[i]["ProjectControl_JobTitle"].ToString()); // if (sgb.GetRow(rowIndex).GetCell(4) == null) sgb.GetRow(rowIndex).CreateCell(4); // sgb.GetRow(rowIndex).GetCell(4).SetCellValue(tb.Rows[i]["PM_General_Priority"].ToString()); // if (sgb.GetRow(rowIndex).GetCell(5) == null) sgb.GetRow(rowIndex).CreateCell(5); // sgb.GetRow(rowIndex).GetCell(5).SetCellValue(tb.Rows[i]["PM_General_Category"].ToString()); // if (sgb.GetRow(rowIndex).GetCell(6) == null) sgb.GetRow(rowIndex).CreateCell(6); // sgb.GetRow(rowIndex).GetCell(6).SetCellValue(tb.Rows[i]["Schedule"].ToString()); // for (int j = 7; j < tb.Columns.Count - 6; j++) // { // if (sgb.GetRow(rowIndex).GetCell(j) == null) sgb.GetRow(rowIndex).CreateCell(j); // sgb.GetRow(rowIndex).GetCell(j).SetCellValue(tb.Rows[i][j + 6].ToString()); // switch (tb.Rows[i][j + 6].ToString()) // { // case "A": // sgb.GetRow(rowIndex).GetCell(j).CellStyle = styleA; // break; // case "B": // sgb.GetRow(rowIndex).GetCell(j).CellStyle = styleB; // break; // case "C": // sgb.GetRow(rowIndex).GetCell(j).CellStyle = styleC; // break; // case "D": // sgb.GetRow(rowIndex).GetCell(j).CellStyle = styleD; // break; // } // } // #endregion // rowIndex++; // } //} //#endregion //#region Rolesview //XSSFSheet rv = (XSSFSheet)hssfworkbook.GetSheet("Rolesview"); //List listParameters = new List(); //if (!string.IsNullOrEmpty(txtJobNo.Text.Trim())) //{ // listParameters.Add(new SqlParameter("@jobno", txtJobNo.Text.Trim())); //} //SqlParameter[] par = listParameters.ToArray(); //DataTable table = SQLHelper.GetDataTableRunProc("Proc_Rolesview", par); //if (table.Rows.Count > 0) //{ // var rowIndex = 2; // for (int i = 0; i < table.Rows.Count; i++) // { // if (rv.GetRow(rowIndex) == null) rv.CreateRow(rowIndex); // #region 列赋值 // if (rv.GetRow(rowIndex).GetCell(0) == null) rv.GetRow(rowIndex).CreateCell(0); // rv.GetRow(rowIndex).GetCell(0).SetCellValue(table.Rows[i]["ProjectControl_BUCode"].ToString()); // if (rv.GetRow(rowIndex).GetCell(1) == null) rv.GetRow(rowIndex).CreateCell(1); // rv.GetRow(rowIndex).GetCell(1).SetCellValue(table.Rows[i]["ProjectControl_JobNo"].ToString()); // if (rv.GetRow(rowIndex).GetCell(2) == null) rv.GetRow(rowIndex).CreateCell(2); // rv.GetRow(rowIndex).GetCell(2).SetCellValue(table.Rows[i]["ProjectControl_JobType"].ToString()); // if (rv.GetRow(rowIndex).GetCell(3) == null) rv.GetRow(rowIndex).CreateCell(3); // rv.GetRow(rowIndex).GetCell(3).SetCellValue(table.Rows[i]["ProjectControl_JobTitle"].ToString()); // if (rv.GetRow(rowIndex).GetCell(4) == null) rv.GetRow(rowIndex).CreateCell(4); // rv.GetRow(rowIndex).GetCell(4).SetCellValue(table.Rows[i]["ProjectControl_JobStatus"].ToString()); // if (rv.GetRow(rowIndex).GetCell(5) == null) rv.GetRow(rowIndex).CreateCell(5); // rv.GetRow(rowIndex).GetCell(5).SetCellValue(table.Rows[i]["PM_General_Priority"].ToString()); // if (rv.GetRow(rowIndex).GetCell(6) == null) rv.GetRow(rowIndex).CreateCell(6); // rv.GetRow(rowIndex).GetCell(6).SetCellValue(table.Rows[i]["ProjectManager"].ToString()); // if (rv.GetRow(rowIndex).GetCell(7) == null) rv.GetRow(rowIndex).CreateCell(7); // rv.GetRow(rowIndex).GetCell(7).SetCellValue(table.Rows[i]["Proc_Designer"].ToString()); // if (rv.GetRow(rowIndex).GetCell(8) == null) rv.GetRow(rowIndex).CreateCell(8); // rv.GetRow(rowIndex).GetCell(8).SetCellValue(table.Rows[i]["Proc_Checker"].ToString()); // if (rv.GetRow(rowIndex).GetCell(9) == null) rv.GetRow(rowIndex).CreateCell(9); // rv.GetRow(rowIndex).GetCell(9).SetCellValue(table.Rows[i]["Proc_Approvers"].ToString()); // if (rv.GetRow(rowIndex).GetCell(10) == null) rv.GetRow(rowIndex).CreateCell(10); // rv.GetRow(rowIndex).GetCell(10).SetCellValue(table.Rows[i]["ME_Designer"].ToString()); // if (rv.GetRow(rowIndex).GetCell(11) == null) rv.GetRow(rowIndex).CreateCell(11); // rv.GetRow(rowIndex).GetCell(11).SetCellValue(table.Rows[i]["ME_Checker"].ToString()); // if (rv.GetRow(rowIndex).GetCell(12) == null) rv.GetRow(rowIndex).CreateCell(12); // rv.GetRow(rowIndex).GetCell(12).SetCellValue(table.Rows[i]["ME_Approvers"].ToString()); // if (rv.GetRow(rowIndex).GetCell(13) == null) rv.GetRow(rowIndex).CreateCell(13); // rv.GetRow(rowIndex).GetCell(13).SetCellValue(table.Rows[i]["PluFF_Designer"].ToString()); // if (rv.GetRow(rowIndex).GetCell(14) == null) rv.GetRow(rowIndex).CreateCell(14); // rv.GetRow(rowIndex).GetCell(14).SetCellValue(table.Rows[i]["PluFF_Checker"].ToString()); // if (rv.GetRow(rowIndex).GetCell(15) == null) rv.GetRow(rowIndex).CreateCell(15); // rv.GetRow(rowIndex).GetCell(15).SetCellValue(table.Rows[i]["PluFF_Approvers"].ToString()); // if (rv.GetRow(rowIndex).GetCell(16) == null) rv.GetRow(rowIndex).CreateCell(16); // rv.GetRow(rowIndex).GetCell(16).SetCellValue(table.Rows[i]["Piping_Designer"].ToString()); // if (rv.GetRow(rowIndex).GetCell(17) == null) rv.GetRow(rowIndex).CreateCell(17); // rv.GetRow(rowIndex).GetCell(17).SetCellValue(table.Rows[i]["Piping_Checker"].ToString()); // if (rv.GetRow(rowIndex).GetCell(18) == null) rv.GetRow(rowIndex).CreateCell(18); // rv.GetRow(rowIndex).GetCell(18).SetCellValue(table.Rows[i]["Piping_Approvers"].ToString()); // if (rv.GetRow(rowIndex).GetCell(19) == null) rv.GetRow(rowIndex).CreateCell(19); // rv.GetRow(rowIndex).GetCell(19).SetCellValue(table.Rows[i]["Ins_Designer"].ToString()); // if (rv.GetRow(rowIndex).GetCell(20) == null) rv.GetRow(rowIndex).CreateCell(20); // rv.GetRow(rowIndex).GetCell(20).SetCellValue(table.Rows[i]["Ins_Checker"].ToString()); // if (rv.GetRow(rowIndex).GetCell(21) == null) rv.GetRow(rowIndex).CreateCell(21); // rv.GetRow(rowIndex).GetCell(21).SetCellValue(table.Rows[i]["Ins_Approvers"].ToString()); // if (rv.GetRow(rowIndex).GetCell(22) == null) rv.GetRow(rowIndex).CreateCell(22); // rv.GetRow(rowIndex).GetCell(22).SetCellValue(table.Rows[i]["Ele_Designer"].ToString()); // if (rv.GetRow(rowIndex).GetCell(23) == null) rv.GetRow(rowIndex).CreateCell(23); // rv.GetRow(rowIndex).GetCell(23).SetCellValue(table.Rows[i]["Ele_Checker"].ToString()); // if (rv.GetRow(rowIndex).GetCell(24) == null) rv.GetRow(rowIndex).CreateCell(24); // rv.GetRow(rowIndex).GetCell(24).SetCellValue(table.Rows[i]["Ele_Approvers"].ToString()); // if (rv.GetRow(rowIndex).GetCell(25) == null) rv.GetRow(rowIndex).CreateCell(25); // rv.GetRow(rowIndex).GetCell(25).SetCellValue(table.Rows[i]["Civ_Designer"].ToString()); // if (rv.GetRow(rowIndex).GetCell(26) == null) rv.GetRow(rowIndex).CreateCell(26); // rv.GetRow(rowIndex).GetCell(26).SetCellValue(table.Rows[i]["Civ_Checker"].ToString()); // if (rv.GetRow(rowIndex).GetCell(27) == null) rv.GetRow(rowIndex).CreateCell(27); // rv.GetRow(rowIndex).GetCell(27).SetCellValue(table.Rows[i]["Civ_Approvers"].ToString()); // if (rv.GetRow(rowIndex).GetCell(28) == null) rv.GetRow(rowIndex).CreateCell(28); // rv.GetRow(rowIndex).GetCell(28).SetCellValue(table.Rows[i]["MP_Designer"].ToString()); // if (rv.GetRow(rowIndex).GetCell(29) == null) rv.GetRow(rowIndex).CreateCell(29); // rv.GetRow(rowIndex).GetCell(29).SetCellValue(table.Rows[i]["MP_Checker"].ToString()); // if (rv.GetRow(rowIndex).GetCell(30) == null) rv.GetRow(rowIndex).CreateCell(30); // rv.GetRow(rowIndex).GetCell(30).SetCellValue(table.Rows[i]["MP_Approvers"].ToString()); // #endregion // rowIndex++; // } //} //#endregion //overview.ForceFormulaRecalculation = true; //pg.ForceFormulaRecalculation = true; //ppv.ForceFormulaRecalculation = true; //sgb.ForceFormulaRecalculation = true; //rv.ForceFormulaRecalculation = true; //using (FileStream filess = File.OpenWrite(ReportFileName)) //{ // hssfworkbook.Write(filess); //} //FileInfo filet = new FileInfo(ReportFileName); //Response.Clear(); //Response.Charset = "GB2312"; //Response.ContentEncoding = System.Text.Encoding.UTF8; //// 添加头信息,为"文件下载/另存为"对话框指定默认文件名 //Response.AddHeader("Content-Disposition", "attachment; filename=P32_Roles_Report_" + Server.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx")); //// 添加头信息,指定文件大小,让浏览器能够显示下载进度 //Response.AddHeader("Content-Length", filet.Length.ToString()); //// 指定返回的是一个不能被客户端读取的流,必须被下载 //Response.ContentType = "application/ms-excel"; //// 把文件流发送到客户端 //Response.WriteFile(filet.FullName); //// 停止页面的执行 //Response.End(); #endregion } private void Export(string strSql, SqlParameter[] parameter, SqlParameter[] par, List Permit_General, List OverviewReport, List PressurePipingVesseReport) { DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); DataTable table = SQLHelper.GetDataTableRunProc("Proc_Rolesview", par); int overNum = OverviewReport.Count(); int prepipingNum = PressurePipingVesseReport.Count(); int permitNum = Permit_General.Count(); int ganttBarNum = tb.Rows.Count; int rolesNum = table.Rows.Count; int totalNum = overNum + permitNum + prepipingNum + ganttBarNum + rolesNum; string rootPath = Server.MapPath("~/") + Const.ExcelUrl; //模板文件 string TempletFileName = rootPath + "RolesReport.xlsx"; //导出文件 string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\"; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string ReportFileName = filePath + "P32_Roles_Report_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx"; FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read); XSSFWorkbook hssfworkbook = new XSSFWorkbook(file); XSSFFont cs_content_Fonts = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 cs_content_Fonts.FontName = "sans-serif";//字体 cs_content_Fonts.FontHeightInPoints = 10; //字体大小 IDataFormat dataformat = hssfworkbook.CreateDataFormat(); ICellStyle styleDate = hssfworkbook.CreateCellStyle(); styleDate.DataFormat = dataformat.GetFormat("yyyy/m/d"); styleDate.SetFont(cs_content_Fonts); #region 背景色、字体设置 #region 黄底 //创建单元格样式 //XSSFCellStyle backgroundstyle = (XSSFCellStyle)hssfworkbook.CreateCellStyle(); ////填充模式 //backgroundstyle.FillPattern = FillPattern.SolidForeground; ////创建颜色 //XSSFColor xssfcolor = new XSSFColor(); ////rbg值 //byte[] rgbYellow = { (byte)250, (byte)250, (byte)210 }; ////写入rgb //xssfcolor.SetRgb(rgbYellow); ////设置颜色值 //backgroundstyle.SetFillForegroundColor(xssfcolor); #endregion #region 黄底黑字 backgroundstyle1 //创建单元格样式 XSSFCellStyle backgroundstyle1 = (XSSFCellStyle)hssfworkbook.CreateCellStyle(); //填充模式 backgroundstyle1.FillPattern = FillPattern.SolidForeground; //创建颜色 XSSFColor xssfcolor1 = new XSSFColor(); //rbg值 byte[] rgbYellow1 = { (byte)250, (byte)250, (byte)210 }; //写入rgb xssfcolor1.SetRgb(rgbYellow1); //设置颜色值 backgroundstyle1.SetFillForegroundColor(xssfcolor1); //创建字体 XSSFFont red_content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 red_content_Font.FontName = "sans-serif";//字体 red_content_Font.FontHeightInPoints = 10; //字体大小 red_content_Font.Color = HSSFColor.Black.Index;//黑字 backgroundstyle1.SetFont(red_content_Font); #endregion #region 黄底红字 backgroundstyle2 //创建单元格样式 XSSFCellStyle backgroundstyle2 = (XSSFCellStyle)hssfworkbook.CreateCellStyle(); //填充模式 backgroundstyle2.FillPattern = FillPattern.SolidForeground; //创建颜色 XSSFColor xssfcolor2 = new XSSFColor(); //rbg值 byte[] rgbYellow2 = { (byte)250, (byte)250, (byte)210 }; //写入rgb xssfcolor2.SetRgb(rgbYellow2); //设置颜色值 backgroundstyle2.SetFillForegroundColor(xssfcolor2); //创建字体 XSSFFont red_content_Font2 = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 red_content_Font2.FontName = "sans-serif";//字体 red_content_Font2.FontHeightInPoints = 10; //字体大小 red_content_Font2.Color = HSSFColor.Red.Index;//黑字 backgroundstyle2.SetFont(red_content_Font2); #endregion #region 红底红字 backgroundstyle3 //创建单元格样式 XSSFCellStyle backgroundstyle3 = (XSSFCellStyle)hssfworkbook.CreateCellStyle(); //填充模式 backgroundstyle3.FillPattern = FillPattern.SolidForeground; //创建颜色 XSSFColor xssfcolor3 = new XSSFColor(); //rbg值 byte[] rgbRed3 = { (byte)244, (byte)164, (byte)96 }; //写入rgb xssfcolor3.SetRgb(rgbRed3); //设置颜色值 backgroundstyle3.SetFillForegroundColor(xssfcolor3); ///创建字体 XSSFFont red_content_Font3 = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 red_content_Font3.FontName = "sans-serif";//字体 red_content_Font3.FontHeightInPoints = 10; //字体大小 red_content_Font3.Color = HSSFColor.Red.Index; backgroundstyle3.SetFont(red_content_Font3); #endregion #region 白底红字 backgroundstyle4 //创建单元格样式 XSSFCellStyle backgroundstyle4 = (XSSFCellStyle)hssfworkbook.CreateCellStyle(); //填充模式 backgroundstyle4.FillPattern = FillPattern.SolidForeground; //创建颜色 XSSFColor xssfcolor4 = new XSSFColor(); //rbg值 byte[] rgbWhite = { (byte)255, (byte)255, (byte)255 };//白色 //写入rgb xssfcolor4.SetRgb(rgbWhite); //设置颜色值 backgroundstyle4.SetFillForegroundColor(xssfcolor4); ///创建字体 XSSFFont red_content_Font4 = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 red_content_Font4.FontName = "sans-serif";//字体 red_content_Font4.FontHeightInPoints = 10; //字体大小 red_content_Font4.Color = HSSFColor.Red.Index; backgroundstyle4.SetFont(red_content_Font4); #endregion #region 红底 //创建单元格样式 XSSFCellStyle redbackgroundstyle = (XSSFCellStyle)hssfworkbook.CreateCellStyle(); //填充模式 redbackgroundstyle.FillPattern = FillPattern.SolidForeground; //创建颜色 XSSFColor xssfredcolor = new XSSFColor(); //rbg值 byte[] rgbRed = { (byte)244, (byte)164, (byte)96 }; //写入rgb xssfredcolor.SetRgb(rgbRed); //设置颜色值 redbackgroundstyle.SetFillForegroundColor(xssfredcolor); redbackgroundstyle.DataFormat= dataformat.GetFormat("yyyy/m/d"); #endregion #endregion #region Overview XSSFSheet overview = (XSSFSheet)hssfworkbook.GetSheet("Overview"); if (OverviewReport.Count > 0) { var rowIndex = 1; foreach (var itemOver in OverviewReport) { if (overview.GetRow(rowIndex) == null) overview.CreateRow(rowIndex); #region 列赋值 if (overview.GetRow(rowIndex).GetCell(0) == null) overview.GetRow(rowIndex).CreateCell(0); overview.GetRow(rowIndex).GetCell(0).SetCellValue(itemOver.ProjectControl_BUCode); if (overview.GetRow(rowIndex).GetCell(1) == null) overview.GetRow(rowIndex).CreateCell(1); overview.GetRow(rowIndex).GetCell(1).SetCellValue(itemOver.ProjectControl_JobNo); if (overview.GetRow(rowIndex).GetCell(2) == null) overview.GetRow(rowIndex).CreateCell(2); overview.GetRow(rowIndex).GetCell(2).SetCellValue(itemOver.ProjectControl_JobType); if (overview.GetRow(rowIndex).GetCell(3) == null) overview.GetRow(rowIndex).CreateCell(3); overview.GetRow(rowIndex).GetCell(3).SetCellValue(itemOver.ProjectControl_LeadByName); if (overview.GetRow(rowIndex).GetCell(4) == null) overview.GetRow(rowIndex).CreateCell(4); overview.GetRow(rowIndex).GetCell(4).SetCellValue(itemOver.ProjectControl_JobTitle); if (overview.GetRow(rowIndex).GetCell(5) == null) overview.GetRow(rowIndex).CreateCell(5); overview.GetRow(rowIndex).GetCell(5).SetCellValue(itemOver.ProjectControl_OrginalBudget.HasValue ? string.Format("{0:N}", (float)itemOver.ProjectControl_OrginalBudget) : ""); if (overview.GetRow(rowIndex).GetCell(6) == null) overview.GetRow(rowIndex).CreateCell(6); overview.GetRow(rowIndex).GetCell(6).SetCellValue(itemOver.ProjectControl_ProjectManager); if (overview.GetRow(rowIndex).GetCell(7) == null) overview.GetRow(rowIndex).CreateCell(7); overview.GetRow(rowIndex).GetCell(7).SetCellValue(itemOver.ProjectControl_ConstManager); if (overview.GetRow(rowIndex).GetCell(8) == null) overview.GetRow(rowIndex).CreateCell(8); if (!string.IsNullOrEmpty(itemOver.PM_MA_ProjectApproval)) { overview.GetRow(rowIndex).GetCell(8).SetCellValue((DateTime)Convert.ToDateTime(itemOver.PM_MA_ProjectApproval.ToString())); overview.GetRow(rowIndex).GetCell(8).CellStyle = styleDate; } if (overview.GetRow(rowIndex).GetCell(9) == null) overview.GetRow(rowIndex).CreateCell(9); if (!string.IsNullOrEmpty(itemOver.ProjectControl_MS_MC)) { overview.GetRow(rowIndex).GetCell(9).SetCellValue((DateTime)Convert.ToDateTime(itemOver.ProjectControl_MS_MC.ToString())); overview.GetRow(rowIndex).GetCell(9).CellStyle = styleDate; } if (overview.GetRow(rowIndex).GetCell(10) == null) overview.GetRow(rowIndex).CreateCell(10); if (!string.IsNullOrEmpty(itemOver.MCRevised)) { overview.GetRow(rowIndex).GetCell(10).SetCellValue((DateTime)Convert.ToDateTime(itemOver.MCRevised.ToString())); overview.GetRow(rowIndex).GetCell(10).CellStyle = styleDate; } if (overview.GetRow(rowIndex).GetCell(11) == null) overview.GetRow(rowIndex).CreateCell(11); overview.GetRow(rowIndex).GetCell(11).SetCellValue(itemOver.PM_General_Priority); if (overview.GetRow(rowIndex).GetCell(12) == null) overview.GetRow(rowIndex).CreateCell(12); overview.GetRow(rowIndex).GetCell(12).SetCellValue(itemOver.PM_General_Category); if (overview.GetRow(rowIndex).GetCell(13) == null) overview.GetRow(rowIndex).CreateCell(13); overview.GetRow(rowIndex).GetCell(13).SetCellValue(itemOver.ProjectControl_JobStatus); if (overview.GetRow(rowIndex).GetCell(14) == null) overview.GetRow(rowIndex).CreateCell(14); overview.GetRow(rowIndex).GetCell(14).SetCellValue(itemOver.Schedule); if (overview.GetRow(rowIndex).GetCell(15) == null) overview.GetRow(rowIndex).CreateCell(15); overview.GetRow(rowIndex).GetCell(15).SetCellValue(itemOver.Cost); if (overview.GetRow(rowIndex).GetCell(16) == null) overview.GetRow(rowIndex).CreateCell(16); overview.GetRow(rowIndex).GetCell(16).SetCellValue(itemOver.Scope); if (overview.GetRow(rowIndex).GetCell(17) == null) overview.GetRow(rowIndex).CreateCell(17); if (!string.IsNullOrEmpty(itemOver.PM_MA_JobReveive)) { overview.GetRow(rowIndex).GetCell(17).SetCellValue((DateTime)Convert.ToDateTime(itemOver.PM_MA_JobReveive.ToString())); overview.GetRow(rowIndex).GetCell(17).CellStyle = styleDate; } if (overview.GetRow(rowIndex).GetCell(18) == null) overview.GetRow(rowIndex).CreateCell(18); overview.GetRow(rowIndex).GetCell(18).SetCellValue(itemOver.EstimatedFinalCost.HasValue ? string.Format("{0:N}", (float)itemOver.EstimatedFinalCost) : ""); if (overview.GetRow(rowIndex).GetCell(19) == null) overview.GetRow(rowIndex).CreateCell(19); if (!string.IsNullOrEmpty(itemOver.MCActual)) { overview.GetRow(rowIndex).GetCell(19).SetCellValue((DateTime)Convert.ToDateTime(itemOver.MCActual.ToString())); overview.GetRow(rowIndex).GetCell(19).CellStyle = styleDate; } if (overview.GetRow(rowIndex).GetCell(20) == null) overview.GetRow(rowIndex).CreateCell(20); if (!string.IsNullOrEmpty(itemOver.MC_Signed)) { overview.GetRow(rowIndex).GetCell(20).SetCellValue((DateTime)Convert.ToDateTime(itemOver.MC_Signed.ToString())); overview.GetRow(rowIndex).GetCell(20).CellStyle = styleDate; } if (overview.GetRow(rowIndex).GetCell(21) == null) overview.GetRow(rowIndex).CreateCell(21); if (!string.IsNullOrEmpty(itemOver.FC_Signed)) { overview.GetRow(rowIndex).GetCell(21).SetCellValue((DateTime)Convert.ToDateTime(itemOver.FC_Signed.ToString())); overview.GetRow(rowIndex).GetCell(21).CellStyle = styleDate; } if (overview.GetRow(rowIndex).GetCell(22) == null) overview.GetRow(rowIndex).CreateCell(22); if (!string.IsNullOrEmpty(itemOver.ProjectControl_BC_CloseDate)) { overview.GetRow(rowIndex).GetCell(22).SetCellValue((DateTime)Convert.ToDateTime(itemOver.ProjectControl_BC_CloseDate.ToString())); overview.GetRow(rowIndex).GetCell(22).CellStyle = styleDate; } if (overview.GetRow(rowIndex).GetCell(23) == null) overview.GetRow(rowIndex).CreateCell(23); if (!string.IsNullOrEmpty(itemOver.IFC_Received)) { overview.GetRow(rowIndex).GetCell(23).SetCellValue((DateTime)Convert.ToDateTime(itemOver.IFC_Received.ToString())); overview.GetRow(rowIndex).GetCell(23).CellStyle = styleDate; } if (overview.GetRow(rowIndex).GetCell(24) == null) overview.GetRow(rowIndex).CreateCell(24); if (!string.IsNullOrEmpty(itemOver.As_built_Received)) { overview.GetRow(rowIndex).GetCell(24).SetCellValue((DateTime)Convert.ToDateTime(itemOver.As_built_Received.ToString())); overview.GetRow(rowIndex).GetCell(24).CellStyle = styleDate; } if (overview.GetRow(rowIndex).GetCell(25) == null) overview.GetRow(rowIndex).CreateCell(25); if (!string.IsNullOrEmpty(itemOver.MD_Received)) { overview.GetRow(rowIndex).GetCell(25).SetCellValue((DateTime)Convert.ToDateTime(itemOver.MD_Received.ToString())); overview.GetRow(rowIndex).GetCell(25).CellStyle = styleDate; } if (overview.GetRow(rowIndex).GetCell(26) == null) overview.GetRow(rowIndex).CreateCell(26); overview.GetRow(rowIndex).GetCell(26).SetCellValue(itemOver.ProjectControl_CostEffectvitity); if (overview.GetRow(rowIndex).GetCell(27) == null) overview.GetRow(rowIndex).CreateCell(27); overview.GetRow(rowIndex).GetCell(27).SetCellValue(itemOver.ProjectControl_PVIPrediction.HasValue ? Math.Round(Convert.ToDouble(itemOver.ProjectControl_PVIPrediction), 2) : 0); if (overview.GetRow(rowIndex).GetCell(28) == null) overview.GetRow(rowIndex).CreateCell(28); if (!string.IsNullOrEmpty(itemOver.ProjectControl_PC_CancelDate)) { overview.GetRow(rowIndex).GetCell(28).SetCellValue((DateTime)Convert.ToDateTime(itemOver.ProjectControl_PC_CancelDate.ToString())); overview.GetRow(rowIndex).GetCell(28).CellStyle = styleDate; } if (overview.GetRow(rowIndex).GetCell(29) == null) overview.GetRow(rowIndex).CreateCell(29); overview.GetRow(rowIndex).GetCell(29).SetCellValue(itemOver.ProjectControl_NetworkNo); if (overview.GetRow(rowIndex).GetCell(30) == null) overview.GetRow(rowIndex).CreateCell(30); overview.GetRow(rowIndex).GetCell(30).SetCellValue(itemOver.PM_General_CDI); #endregion #region 填充背景色 //超出计划MC6个月,仍未有实际MC日期(MC Actual) if (!string.IsNullOrEmpty(itemOver.ProjectControl_MS_MC)) { if (Funs.GetNewDateTime(itemOver.ProjectControl_MS_MC).Value.AddMonths(6) < Funs.GetNewDateTime(DateTime.Now.ToShortDateString()) && string.IsNullOrEmpty(itemOver.MCActual)) { overview.GetRow(rowIndex).GetCell(20).CellStyle = redbackgroundstyle; } } //超出实际MC10天,仍未签MC证书(MC Signed) if (!string.IsNullOrEmpty(itemOver.MCActual)) { if (Funs.GetNewDateTime(itemOver.MCActual).Value.AddDays(10) < Funs.GetNewDateTime(DateTime.Now.ToShortDateString()) && string.IsNullOrEmpty(itemOver.MC_Signed)) { overview.GetRow(rowIndex).GetCell(21).CellStyle = redbackgroundstyle; } } //超出实际MC90天,仍未签FC证书(FC Signed) if (!string.IsNullOrEmpty(itemOver.MCActual)) { if (Funs.GetNewDateTime(itemOver.MCActual).Value.AddDays(90) < Funs.GetNewDateTime(DateTime.Now.ToShortDateString()) && string.IsNullOrEmpty(itemOver.FC_Signed)) { overview.GetRow(rowIndex).GetCell(22).CellStyle = redbackgroundstyle; } } //超出FC180天,仍未商务关闭的(Business Closed) if (!string.IsNullOrEmpty(itemOver.FC_Signed)) { if (Funs.GetNewDateTime(itemOver.FC_Signed).Value.AddDays(180) < Funs.GetNewDateTime(DateTime.Now.ToShortDateString()) && string.IsNullOrEmpty(itemOver.ProjectControl_BC_CloseDate)) { overview.GetRow(rowIndex).GetCell(23).CellStyle = redbackgroundstyle; } } //超出实际MC90天,仍未收到AB的(As-built Received) if (!string.IsNullOrEmpty(itemOver.MCActual)) { if (Funs.GetNewDateTime(itemOver.MCActual).Value.AddDays(90) < Funs.GetNewDateTime(DateTime.Now.ToShortDateString()) && string.IsNullOrEmpty(itemOver.As_built_Received)) { overview.GetRow(rowIndex).GetCell(25).CellStyle = redbackgroundstyle; } } #endregion if ((int)(95 * rowIndex / totalNum) > percent) { percent = (int)(100 * rowIndex / totalNum); } rowIndex++; } } #endregion #region Permit_General XSSFSheet pg = (XSSFSheet)hssfworkbook.GetSheet("Permit_General"); if (Permit_General.Count > 0) { var rowIndex = 1; foreach (var item in Permit_General) { if (pg.GetRow(rowIndex) == null) pg.CreateRow(rowIndex); #region 列赋值 if (item.PType == "计划") { if (pg.GetRow(rowIndex).GetCell(0) == null) pg.GetRow(rowIndex).CreateCell(0); pg.GetRow(rowIndex).GetCell(0).SetCellValue(item.ProjectControl_JobNo); pg.GetRow(rowIndex).GetCell(0).CellStyle.SetFont(cs_content_Fonts);//将字体绑定到样式 if (pg.GetRow(rowIndex).GetCell(1) == null) pg.GetRow(rowIndex).CreateCell(1); pg.GetRow(rowIndex).GetCell(1).SetCellValue(item.ProjectControl_JobTitle); pg.GetRow(rowIndex).GetCell(1).CellStyle.SetFont(cs_content_Fonts); if (pg.GetRow(rowIndex).GetCell(2) == null) pg.GetRow(rowIndex).CreateCell(2); pg.GetRow(rowIndex).GetCell(2).SetCellValue(item.ProjectControl_ProjectManager); pg.GetRow(rowIndex).GetCell(2).CellStyle.SetFont(cs_content_Fonts); } if (pg.GetRow(rowIndex).GetCell(3) == null) pg.GetRow(rowIndex).CreateCell(3); pg.GetRow(rowIndex).GetCell(3).SetCellValue(item.PType); pg.GetRow(rowIndex).GetCell(3).CellStyle.SetFont(cs_content_Fonts); if (pg.GetRow(rowIndex).GetCell(4) == null) pg.GetRow(rowIndex).CreateCell(4); pg.GetRow(rowIndex).GetCell(4).SetCellValue(item.EnvAssess); pg.GetRow(rowIndex).GetCell(4).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(4).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(4).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(5) == null) pg.GetRow(rowIndex).CreateCell(5); pg.GetRow(rowIndex).GetCell(5).SetCellValue(item.EnergySaving); pg.GetRow(rowIndex).GetCell(5).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(5).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(5).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(6) == null) pg.GetRow(rowIndex).CreateCell(6); pg.GetRow(rowIndex).GetCell(6).SetCellValue(item.ProjectRegistr); pg.GetRow(rowIndex).GetCell(6).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(6).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(6).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(7) == null) pg.GetRow(rowIndex).CreateCell(7); pg.GetRow(rowIndex).GetCell(7).SetCellValue(item.PlanningPermit); pg.GetRow(rowIndex).GetCell(7).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(7).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(7).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(8) == null) pg.GetRow(rowIndex).CreateCell(8); pg.GetRow(rowIndex).GetCell(8).SetCellValue(item.SafetyConReview); pg.GetRow(rowIndex).GetCell(8).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(8).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(8).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(9) == null) pg.GetRow(rowIndex).CreateCell(9); pg.GetRow(rowIndex).GetCell(9).SetCellValue(item.SafetyDesginReview); pg.GetRow(rowIndex).GetCell(9).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(9).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(9).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(10) == null) pg.GetRow(rowIndex).CreateCell(10); pg.GetRow(rowIndex).GetCell(10).SetCellValue(item.FFDesginReview); pg.GetRow(rowIndex).GetCell(10).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(10).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(10).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(11) == null) pg.GetRow(rowIndex).CreateCell(11); pg.GetRow(rowIndex).GetCell(11).SetCellValue(item.ConstPermit); pg.GetRow(rowIndex).GetCell(11).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(11).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(11).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(12) == null) pg.GetRow(rowIndex).CreateCell(12); pg.GetRow(rowIndex).GetCell(12).SetCellValue(item.CMStart); pg.GetRow(rowIndex).GetCell(12).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(12).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(12).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(13) == null) pg.GetRow(rowIndex).CreateCell(13); pg.GetRow(rowIndex).GetCell(13).SetCellValue(item.MC); pg.GetRow(rowIndex).GetCell(13).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(13).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(13).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(14) == null) pg.GetRow(rowIndex).CreateCell(14); pg.GetRow(rowIndex).GetCell(14).SetCellValue(item.SafetyFinalAcc); pg.GetRow(rowIndex).GetCell(14).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(14).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(14).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(15) == null) pg.GetRow(rowIndex).CreateCell(15); pg.GetRow(rowIndex).GetCell(15).SetCellValue(item.FFFinalAcc); pg.GetRow(rowIndex).GetCell(15).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(15).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(15).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(16) == null) pg.GetRow(rowIndex).CreateCell(16); pg.GetRow(rowIndex).GetCell(16).SetCellValue(item.Usin); pg.GetRow(rowIndex).GetCell(16).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(16).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(16).CellStyle.Alignment = HorizontalAlignment.Center; if (pg.GetRow(rowIndex).GetCell(17) == null) pg.GetRow(rowIndex).CreateCell(17); pg.GetRow(rowIndex).GetCell(17).SetCellValue(item.EnvFinalAcc); pg.GetRow(rowIndex).GetCell(17).CellStyle.SetFont(cs_content_Fonts); pg.GetRow(rowIndex).GetCell(17).CellStyle.VerticalAlignment = VerticalAlignment.Center; pg.GetRow(rowIndex).GetCell(17).CellStyle.Alignment = HorizontalAlignment.Center; #endregion #region 填充背景色 if (item.PType == "计划") { #region 设置计划行背景色 pg.GetRow(rowIndex).GetCell(0).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(1).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(2).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(3).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(9).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(10).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(11).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(12).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(13).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(14).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(15).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(16).CellStyle = backgroundstyle1; pg.GetRow(rowIndex).GetCell(17).CellStyle = backgroundstyle1; #endregion #region 如果距计划日期还有超过一个月的时间,则计划日期显示黄底黑字 if (item.EnvAssess != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.EnvAssess))//环评 { pg.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle1; } if (item.EnergySaving != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.EnergySaving))//节能报告 { pg.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle1; } if (item.ProjectRegistr != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.ProjectRegistr))//项目备案 { pg.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle1; } if (item.PlanningPermit != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.PlanningPermit))//规划许可 { pg.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle1; } if (item.SafetyConReview != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.SafetyConReview))//安全条件审查 { pg.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle1; } if (item.SafetyDesginReview != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.SafetyDesginReview))//安全设施设计审查 { pg.GetRow(rowIndex).GetCell(9).CellStyle = backgroundstyle1; } if (item.FFDesginReview != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.FFDesginReview))//消防设计审查 { pg.GetRow(rowIndex).GetCell(10).CellStyle = backgroundstyle1; } if (item.ConstPermit != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.ConstPermit))//施工许可 { pg.GetRow(rowIndex).GetCell(11).CellStyle = backgroundstyle1; } //if (item.CMStart != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.CMStart))//施工开始 //{ // pg.GetRow(rowIndex).GetCell(12).CellStyle = backgroundstyle1; //} //if (item.MC != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.MC))//机械竣工 //{ // pg.GetRow(rowIndex).GetCell(13).CellStyle = backgroundstyle1; //} if (item.SafetyFinalAcc != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.SafetyFinalAcc))//安全设施竣工验收 { pg.GetRow(rowIndex).GetCell(14).CellStyle = backgroundstyle1; } if (item.FFFinalAcc != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.FFFinalAcc))//消防设施竣工验收 { pg.GetRow(rowIndex).GetCell(15).CellStyle = backgroundstyle1; } //if (item.Usin != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.Usin))//投用 //{ // pg.GetRow(rowIndex).GetCell(16).CellStyle = backgroundstyle1; //} if (item.EnvFinalAcc != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.EnvFinalAcc))//环保设施竣工验收 { pg.GetRow(rowIndex).GetCell(17).CellStyle = backgroundstyle1; } #endregion #region 如果下月须完成,则显示黄底红字 if (item.EnvAssess != "-" && DateTime.Now.Year == Convert.ToDateTime(item.EnvAssess).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.EnvAssess).Month) { pg.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle2;//环评 } if (item.EnergySaving != "-" && DateTime.Now.Year == Convert.ToDateTime(item.EnergySaving).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.EnergySaving).Month) { pg.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle2;//节能报告 } if (item.ProjectRegistr != "-" && DateTime.Now.Year == Convert.ToDateTime(item.ProjectRegistr).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.ProjectRegistr).Month) { pg.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle2;//项目备案 } if (item.PlanningPermit != "-" && DateTime.Now.Year == Convert.ToDateTime(item.PlanningPermit).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.PlanningPermit).Month) { pg.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle2;//规划许可 } if (item.SafetyConReview != "-" && DateTime.Now.Year == Convert.ToDateTime(item.SafetyConReview).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.SafetyConReview).Month) { pg.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle2;//安全条件审查 } if (item.SafetyDesginReview != "-" && DateTime.Now.Year == Convert.ToDateTime(item.SafetyDesginReview).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.SafetyDesginReview).Month) { pg.GetRow(rowIndex).GetCell(9).CellStyle = backgroundstyle2;//安全设施设计审查 } if (item.FFDesginReview != "-" && DateTime.Now.Year == Convert.ToDateTime(item.FFDesginReview).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.FFDesginReview).Month) { pg.GetRow(rowIndex).GetCell(10).CellStyle = backgroundstyle2;//消防设计审查 } if (item.ConstPermit != "-" && DateTime.Now.Year == Convert.ToDateTime(item.ConstPermit).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.ConstPermit).Month) { pg.GetRow(rowIndex).GetCell(11).CellStyle = backgroundstyle2;//施工许可 } //if (item.CMStart != "-" && DateTime.Now.Year == Convert.ToDateTime(item.CMStart).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.CMStart).Month) //{ // pg.GetRow(rowIndex).GetCell(12).CellStyle = backgroundstyle2;//施工开始 //} //if (item.MC != "-" && DateTime.Now.Year == Convert.ToDateTime(item.MC).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.MC).Month) //{ // pg.GetRow(rowIndex).GetCell(13).CellStyle = backgroundstyle2;//机械竣工 //} if (item.SafetyFinalAcc != "-" && DateTime.Now.Year == Convert.ToDateTime(item.SafetyFinalAcc).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.SafetyFinalAcc).Month) { pg.GetRow(rowIndex).GetCell(14).CellStyle = backgroundstyle2;//安全设施竣工验收 } if (item.FFFinalAcc != "-" && DateTime.Now.Year == Convert.ToDateTime(item.FFFinalAcc).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.FFFinalAcc).Month) { pg.GetRow(rowIndex).GetCell(15).CellStyle = backgroundstyle2;//消防设施竣工验收 } //if (item.Usin != "-" && DateTime.Now.Year == Convert.ToDateTime(item.Usin).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.Usin).Month) //{ // pg.GetRow(rowIndex).GetCell(16).CellStyle = backgroundstyle2;//投用 //} if (item.EnvFinalAcc != "-" && DateTime.Now.Year == Convert.ToDateTime(item.EnvFinalAcc).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.EnvFinalAcc).Month) { pg.GetRow(rowIndex).GetCell(17).CellStyle = backgroundstyle2;//环保设施竣工验收 } #endregion #region 如果已过计划日期一个月,但还未完成,则显示红底红字 var actual = (from x in Funs.DB.View_Report_PermitGeneral where x.ProjectControl_JobNo == item.ProjectControl_JobNo && x.PType == "实际" select x).FirstOrDefault(); if (actual != null) { if (item.EnvAssess != "-" && Convert.ToDateTime(item.EnvAssess).AddMonths(1) < DateTime.Now)//环评 { if (actual.EnvAssess == "-") { pg.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle3; } } if (item.EnergySaving != "-" && Convert.ToDateTime(item.EnergySaving).AddMonths(1) < DateTime.Now)//节能报告 { if (actual.EnergySaving == "-") { pg.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle3; } } if (item.ProjectRegistr != "-" && Convert.ToDateTime(item.ProjectRegistr).AddMonths(1) < DateTime.Now)//项目备案 { if (actual.ProjectRegistr == "-") { pg.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle3; } } if (item.PlanningPermit != "-" && Convert.ToDateTime(item.PlanningPermit).AddMonths(1) < DateTime.Now)//规划许可 { if (actual.PlanningPermit == "-") { pg.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle3; } } if (item.SafetyConReview != "-" && Convert.ToDateTime(item.SafetyConReview).AddMonths(1) < DateTime.Now)//安全条件审查 { if (actual.SafetyConReview == "-") { pg.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle3; } } if (item.SafetyDesginReview != "-" && Convert.ToDateTime(item.SafetyDesginReview).AddMonths(1) < DateTime.Now)//安全设施设计审查 { if (actual.SafetyDesginReview == "-") { pg.GetRow(rowIndex).GetCell(9).CellStyle = backgroundstyle3; } } if (item.FFDesginReview != "-" && Convert.ToDateTime(item.FFDesginReview).AddMonths(1) < DateTime.Now)//消防设计审查 { if (actual.FFDesginReview == "-") { pg.GetRow(rowIndex).GetCell(10).CellStyle = backgroundstyle3; } } if (item.ConstPermit != "-" && Convert.ToDateTime(item.ConstPermit).AddMonths(1) < DateTime.Now)//施工许可 { if (actual.ConstPermit == "-") { pg.GetRow(rowIndex).GetCell(11).CellStyle = backgroundstyle3; } } //if (item.CMStart != "-" && Convert.ToDateTime(item.CMStart).AddMonths(1) < DateTime.Now )//施工开始 //{ // if (actual.CMStart == "-") // { // pg.GetRow(rowIndex).GetCell(12).CellStyle = backgroundstyle3; // } //} //if (item.MC != "-" && Convert.ToDateTime(item.MC).AddMonths(1) < DateTime.Now )//机械竣工 //{ // if (actual.MC == "-") // { // pg.GetRow(rowIndex).GetCell(13).CellStyle = backgroundstyle3; // } //} if (item.SafetyFinalAcc != "-" && Convert.ToDateTime(item.SafetyFinalAcc).AddMonths(1) < DateTime.Now)//安全设施竣工验收 { if (actual.SafetyFinalAcc == "-") { pg.GetRow(rowIndex).GetCell(14).CellStyle = backgroundstyle3; } } if (item.FFFinalAcc != "-" && Convert.ToDateTime(item.FFFinalAcc).AddMonths(1) < DateTime.Now)//消防设施竣工验收 { if (actual.FFFinalAcc == "-") { pg.GetRow(rowIndex).GetCell(15).CellStyle = backgroundstyle3; } } //if (item.Usin != "-" && Convert.ToDateTime(item.Usin).AddMonths(1) < DateTime.Now)//投用 //{ // if (actual.Usin == "-") // { // pg.GetRow(rowIndex).GetCell(16).CellStyle = backgroundstyle3; // } //} if (item.EnvFinalAcc != "-" && Convert.ToDateTime(item.EnvFinalAcc).AddMonths(1) < DateTime.Now)//环保设施竣工验收 { if (actual.EnvFinalAcc == "-") { pg.GetRow(rowIndex).GetCell(17).CellStyle = backgroundstyle3; } } } #endregion #region 一旦实际日期栏填入数据,则计划日期恢复成黄底黑字 var eproject = BLL.EProjectService.GeteProjectByJobNO(item.ProjectControl_JobNo); if (eproject != null) { if (eproject.Permit_PPA_EnvAssess.HasValue && item.EnvAssess != "-") { pg.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle1;//环评 } if (eproject.Permit_PPA_EnergySaving.HasValue && item.EnergySaving != "-") { pg.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle1;//节能报告 } if (eproject.Permit_PPA_ProjectRegistration.HasValue && item.ProjectRegistr != "-") { pg.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle1;//项目备案 } if (eproject.Permit_PPA_PlanningPermit.HasValue && item.PlanningPermit != "-") { pg.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle1;//规划许可 } if (eproject.Permit_PPA_SafetyConRev.HasValue && item.SafetyConReview != "-") { pg.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle1;//安全条件审查 } if (eproject.Permit_PPA_SafetyDesignRev.HasValue && item.SafetyDesginReview != "-") { pg.GetRow(rowIndex).GetCell(9).CellStyle = backgroundstyle1;//安全设施设计审查 } if (eproject.Permit_PPA_FFDesignReview.HasValue && item.FFDesginReview != "-") { pg.GetRow(rowIndex).GetCell(10).CellStyle = backgroundstyle1;//消防设计审查 } if (eproject.Permit_PA_ConstPermit.HasValue && item.ConstPermit != "-") { pg.GetRow(rowIndex).GetCell(11).CellStyle = backgroundstyle1;//施工许可 } //if (eproject.Permit_PA_ConstPermit.HasValue&&item.CMStart!="-") //{ // pg.GetRow(rowIndex).GetCell(12).CellStyle = backgroundstyle1;//施工开始 //} //if (eproject.CM_MA_MC.HasValue && item.MC != "-") //{ // pg.GetRow(rowIndex).GetCell(13).CellStyle = backgroundstyle1;//机械竣工 //} if (eproject.Permit_PA_SafetyFinalACC.HasValue && item.SafetyFinalAcc != "-") { pg.GetRow(rowIndex).GetCell(14).CellStyle = backgroundstyle1;//安全设施竣工验收 } if (eproject.Permit_PA_FFFinalACC.HasValue && item.FFFinalAcc != "-") { pg.GetRow(rowIndex).GetCell(15).CellStyle = backgroundstyle1;//消防设施竣工验收 } //if (eproject.CM_MA_MC.HasValue && item.Usin != "-") //{ // pg.GetRow(rowIndex).GetCell(16).CellStyle = backgroundstyle1;//投用 //} if (eproject.Permit_PA_EnvFinalACC.HasValue && item.EnvFinalAcc != "-") { pg.GetRow(rowIndex).GetCell(17).CellStyle = backgroundstyle1;//环保设施竣工验收 } } #endregion } if (item.PType == "实际") { var plan = (from x in Funs.DB.View_Report_PermitGeneral where x.ProjectControl_JobNo == item.ProjectControl_JobNo && x.PType == "计划" select x).FirstOrDefault(); if (plan != null) { //如果提前或按时完成,则显示白底黑字 //if (!string.IsNullOrEmpty(item.EnvAssess) && !string.IsNullOrEmpty(plan.EnvAssess) && item.EnvAssess != "-" && plan.EnvAssess != "-" && Convert.ToDateTime(item.EnvAssess) <= Convert.ToDateTime(plan.EnvAssess)) //{ //} #region 如果是在计划日期后完成,则显示白底红字 if (plan.EnvAssess != "-" && item.EnvAssess != "-" && Convert.ToDateTime(plan.EnvAssess) < Convert.ToDateTime(item.EnvAssess)) { pg.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle4;//环评 } if (plan.EnergySaving != "-" && item.EnergySaving != "-" && Convert.ToDateTime(plan.EnergySaving) < Convert.ToDateTime(item.EnergySaving)) { pg.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle4;//节能报告 } if (plan.ProjectRegistr != "-" && item.ProjectRegistr != "-" && Convert.ToDateTime(plan.ProjectRegistr) < Convert.ToDateTime(item.ProjectRegistr)) { pg.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle4;//项目备案 } if (plan.PlanningPermit != "-" && item.PlanningPermit != "-" && Convert.ToDateTime(plan.PlanningPermit) < Convert.ToDateTime(item.PlanningPermit)) { pg.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle4;//规划许可 } if (plan.SafetyConReview != "-" && item.SafetyConReview != "-" && Convert.ToDateTime(plan.SafetyConReview) < Convert.ToDateTime(item.SafetyConReview)) { pg.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle4;//安全条件审查 } if (plan.SafetyDesginReview != "-" && item.SafetyDesginReview != "-" && Convert.ToDateTime(plan.SafetyDesginReview) < Convert.ToDateTime(item.SafetyDesginReview)) { pg.GetRow(rowIndex).GetCell(9).CellStyle = backgroundstyle4;//安全设施设计审查 } if (plan.FFDesginReview != "-" && item.FFDesginReview != "-" && Convert.ToDateTime(plan.FFDesginReview) < Convert.ToDateTime(item.FFDesginReview)) { pg.GetRow(rowIndex).GetCell(10).CellStyle = backgroundstyle4;//消防设计审查 } if (plan.ConstPermit != "-" && item.ConstPermit != "-" && Convert.ToDateTime(plan.ConstPermit) < Convert.ToDateTime(item.ConstPermit)) { pg.GetRow(rowIndex).GetCell(11).CellStyle = backgroundstyle4;//施工许可 } //if (plan.CMStart != "-" && item.CMStart != "-" && Convert.ToDateTime(plan.CMStart) < Convert.ToDateTime(item.CMStart)) //{ // pg.GetRow(rowIndex).GetCell(12).CellStyle = backgroundstyle4;//施工开始 //} //if (plan.MC != "-" && item.MC != "-" && Convert.ToDateTime(plan.MC) < Convert.ToDateTime(item.MC)) //{ // pg.GetRow(rowIndex).GetCell(13).CellStyle = backgroundstyle4;//机械竣工 //} if (plan.SafetyFinalAcc != "-" && item.SafetyFinalAcc != "-" && Convert.ToDateTime(plan.SafetyFinalAcc) < Convert.ToDateTime(item.SafetyFinalAcc)) { pg.GetRow(rowIndex).GetCell(14).CellStyle = backgroundstyle4;//安全设施竣工验收 } if (plan.FFFinalAcc != "-" && item.FFFinalAcc != "-" && Convert.ToDateTime(plan.FFFinalAcc) < Convert.ToDateTime(item.FFFinalAcc)) { pg.GetRow(rowIndex).GetCell(15).CellStyle = backgroundstyle4;//消防设施竣工验收 } //if (plan.Usin != "-" && item.Usin != "-" && Convert.ToDateTime(plan.Usin) < Convert.ToDateTime(item.Usin)) //{ // pg.GetRow(rowIndex).GetCell(16).CellStyle = backgroundstyle4;//投用 //} if (plan.EnvFinalAcc != "-" && item.EnvFinalAcc != "-" && Convert.ToDateTime(plan.EnvFinalAcc) < Convert.ToDateTime(item.EnvFinalAcc)) { pg.GetRow(rowIndex).GetCell(17).CellStyle = backgroundstyle4;//环保设施竣工验收 } #endregion } } #endregion if ((int)((95 * (rowIndex + overNum)) / totalNum) > percent) { percent = (int)(100 * (rowIndex + overNum) / totalNum); } rowIndex++; } } #endregion #region Permit_Pressure Piping & Vesse XSSFSheet ppv = (XSSFSheet)hssfworkbook.GetSheet("Permit_Pressure Piping & Vesse"); if (PressurePipingVesseReport.Count > 0) { var rowIndex = 1; foreach (var item in PressurePipingVesseReport) { if (ppv.GetRow(rowIndex) == null) ppv.CreateRow(rowIndex); #region 列赋值 if (item.PType == "计划") { if (ppv.GetRow(rowIndex).GetCell(0) == null) ppv.GetRow(rowIndex).CreateCell(0); ppv.GetRow(rowIndex).GetCell(0).SetCellValue(item.ProjectControl_JobNo); ppv.GetRow(rowIndex).GetCell(0).CellStyle.SetFont(cs_content_Fonts);//将字体绑定到样式 if (ppv.GetRow(rowIndex).GetCell(1) == null) ppv.GetRow(rowIndex).CreateCell(1); ppv.GetRow(rowIndex).GetCell(1).SetCellValue(item.ProjectControl_JobTitle); ppv.GetRow(rowIndex).GetCell(1).CellStyle.SetFont(cs_content_Fonts); if (ppv.GetRow(rowIndex).GetCell(2) == null) ppv.GetRow(rowIndex).CreateCell(2); ppv.GetRow(rowIndex).GetCell(2).SetCellValue(item.ProjectControl_ProjectManager); ppv.GetRow(rowIndex).GetCell(2).CellStyle.SetFont(cs_content_Fonts); } if (ppv.GetRow(rowIndex).GetCell(3) == null) ppv.GetRow(rowIndex).CreateCell(3); ppv.GetRow(rowIndex).GetCell(3).SetCellValue(item.PType); ppv.GetRow(rowIndex).GetCell(3).CellStyle.SetFont(cs_content_Fonts); if (ppv.GetRow(rowIndex).GetCell(4) == null) ppv.GetRow(rowIndex).CreateCell(4); ppv.GetRow(rowIndex).GetCell(4).SetCellValue(item.PressurePiping); ppv.GetRow(rowIndex).GetCell(4).CellStyle.SetFont(cs_content_Fonts); if (ppv.GetRow(rowIndex).GetCell(5) == null) ppv.GetRow(rowIndex).CreateCell(5); ppv.GetRow(rowIndex).GetCell(5).SetCellValue(item.PressureVessel); ppv.GetRow(rowIndex).GetCell(5).CellStyle.SetFont(cs_content_Fonts); if (ppv.GetRow(rowIndex).GetCell(6) == null) ppv.GetRow(rowIndex).CreateCell(6); ppv.GetRow(rowIndex).GetCell(6).SetCellValue(item.SQIB); ppv.GetRow(rowIndex).GetCell(6).CellStyle.SetFont(cs_content_Fonts); if (ppv.GetRow(rowIndex).GetCell(7) == null) ppv.GetRow(rowIndex).CreateCell(7); ppv.GetRow(rowIndex).GetCell(7).SetCellValue(item.ArchiveAccep); ppv.GetRow(rowIndex).GetCell(7).CellStyle.SetFont(cs_content_Fonts); if (ppv.GetRow(rowIndex).GetCell(8) == null) ppv.GetRow(rowIndex).CreateCell(8); ppv.GetRow(rowIndex).GetCell(8).SetCellValue(item.ThrdConstJian); ppv.GetRow(rowIndex).GetCell(8).CellStyle.SetFont(cs_content_Fonts); #endregion #region 填充背景色 if (item.PType == "计划") { #region 设置计划行背景色 ppv.GetRow(rowIndex).GetCell(0).CellStyle = backgroundstyle1; ppv.GetRow(rowIndex).GetCell(1).CellStyle = backgroundstyle1; ppv.GetRow(rowIndex).GetCell(2).CellStyle = backgroundstyle1; ppv.GetRow(rowIndex).GetCell(3).CellStyle = backgroundstyle1; ppv.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle1; ppv.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle1; ppv.GetRow(rowIndex).GetCell(6).CellStyle = backgroundstyle1; ppv.GetRow(rowIndex).GetCell(7).CellStyle = backgroundstyle1; ppv.GetRow(rowIndex).GetCell(8).CellStyle = backgroundstyle1; #endregion #region 如果距计划日期还有超过一个月的时间,则计划日期显示黄底黑字 if (item.PressurePiping != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.PressurePiping))//压力管道 { ppv.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle1; } if (item.PressureVessel != "-" && DateTime.Now.AddMonths(1) < Convert.ToDateTime(item.PressureVessel))//压力容器 { ppv.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle1; } #endregion #region 如果下月须完成,则显示黄底红字 if (item.PressurePiping != "-" && DateTime.Now.Year == Convert.ToDateTime(item.PressurePiping).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.PressurePiping).Month) { ppv.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle2;//压力管道 } if (item.PressureVessel != "-" && DateTime.Now.Year == Convert.ToDateTime(item.PressureVessel).Year && DateTime.Now.AddMonths(1).Month == Convert.ToDateTime(item.PressureVessel).Month) { ppv.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle2;//压力容器 } #endregion #region 如果已过计划日期一个月,但还未完成,则显示红底红字 var actual = (from x in Funs.DB.View_Report_Permit_PressurePipingVesse where x.ProjectControl_JobNo == item.ProjectControl_JobNo && x.PType == "实际" select x).FirstOrDefault(); if (actual != null) { if (item.PressurePiping != "-" && Convert.ToDateTime(item.PressurePiping).AddMonths(1) < DateTime.Now)//压力管道 { if (actual.PressurePiping == "-") { ppv.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle3; } } if (item.PressureVessel != "-" && Convert.ToDateTime(item.PressureVessel).AddMonths(1) < DateTime.Now)//压力容器 { if (actual.PressureVessel == "-") { ppv.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle3; } } } #endregion #region 一旦实际日期栏填入数据,则计划日期恢复成黄底黑字 var eproject = BLL.EProjectService.GeteProjectByJobNO(item.ProjectControl_JobNo); if (eproject != null) { if (eproject.SQIB_PressurePiping.HasValue && item.PressurePiping != "-") { ppv.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle1;//压力管道 } if (eproject.SQIB_PressureVessel.HasValue && item.PressureVessel != "-") { ppv.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle1;//压力容器 } } #endregion } if (item.PType == "实际") { var plan = (from x in Funs.DB.View_Report_Permit_PressurePipingVesse where x.ProjectControl_JobNo == item.ProjectControl_JobNo && x.PType == "计划" select x).FirstOrDefault(); if (plan != null) { //如果提前或按时完成,则显示白底黑字 //if (!string.IsNullOrEmpty(item.EnvAssess) && !string.IsNullOrEmpty(plan.EnvAssess) && item.EnvAssess != "-" && plan.EnvAssess != "-" && Convert.ToDateTime(item.EnvAssess) <= Convert.ToDateTime(plan.EnvAssess)) //{ //} #region 如果是在计划日期后完成,则显示白底红字 if (plan.PressurePiping != "-" && item.PressurePiping != "-" && Convert.ToDateTime(plan.PressurePiping) < Convert.ToDateTime(item.PressurePiping)) { ppv.GetRow(rowIndex).GetCell(4).CellStyle = backgroundstyle4;//压力管道 } if (plan.PressureVessel != "-" && item.PressureVessel != "-" && Convert.ToDateTime(plan.PressureVessel) < Convert.ToDateTime(item.PressureVessel)) { ppv.GetRow(rowIndex).GetCell(5).CellStyle = backgroundstyle4;//压力容器 } #endregion } } #endregion if ((int)((95 * (rowIndex + overNum + permitNum)) / totalNum) > percent) { percent = (int)(100 * (rowIndex + overNum + permitNum) / totalNum); } rowIndex++; } } #endregion #region Schedule_Gantt_Bar XSSFSheet sgb = (XSSFSheet)hssfworkbook.GetSheet("Schedule_Gantt_Bar"); GregorianCalendar gc = new GregorianCalendar(); for (int i = -3; i < 2; i++) { DateTime dateTime = new DateTime(DateTime.Now.Year + i, 12, 31); for (int j = 1; j <= gc.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday); j++) { tb.Columns.Add(dateTime.Year + "-" + j, System.Type.GetType("System.String")); } } for (int i = 0; i < tb.Rows.Count; i++) { try { var ReceiveDate = tb.Rows[i]["ReceiveDate"]; var ApprovalDate = tb.Rows[i]["ApprovalDate"]; var ConstStart = tb.Rows[i]["ConstMECivilStart"]; var DEMEEnd = tb.Rows[i]["DEMECivilEnd"]; var ConstEnd = tb.Rows[i]["ConstMECivilEnd"]; if (ReceiveDate is DateTime && ApprovalDate is DateTime) { DateTime start = (DateTime)ReceiveDate; DateTime end = (DateTime)ApprovalDate; for (; start < end; start = start.AddDays(7)) { if (tb.Columns.Contains(start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday))) tb.Rows[i][start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday)] = "A"; } } if (ApprovalDate is DateTime && ConstStart is DateTime) { DateTime start = (DateTime)ApprovalDate; DateTime end = (DateTime)ConstStart; for (; start < end; start = start.AddDays(7)) { if (tb.Columns.Contains(start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday))) tb.Rows[i][start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday)] = "B"; } } if (ConstStart is DateTime && DEMEEnd is DateTime) { DateTime start = (DateTime)ConstStart; DateTime end = (DateTime)DEMEEnd; for (; start < end; start = start.AddDays(7)) { if (tb.Columns.Contains(start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday))) tb.Rows[i][start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday)] = "C"; } } if (DEMEEnd is DateTime && ConstEnd is DateTime) { DateTime start = (DateTime)DEMEEnd; DateTime end = (DateTime)ConstEnd; for (; start < end; start = start.AddDays(7)) { if (tb.Columns.Contains(start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday))) tb.Rows[i][start.Year + "-" + gc.GetWeekOfYear(start, CalendarWeekRule.FirstDay, DayOfWeek.Monday)] = "D"; } } } catch (Exception e1) { } } //计算excel表头 int index = 1; XSSFFont cs_content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 cs_content_Font.FontName = "Arial";//字体 cs_content_Font.FontHeightInPoints = 10; //字体大小 ICellStyle styleToday = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 styleToday.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Pink.Index; styleToday.FillPattern = FillPattern.SolidForeground; for (int i = -3; i < 2; i++) { DateTime dateTime = new DateTime(DateTime.Now.Year + i, 12, 31); ICellStyle styleTitle = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 switch (i) { case -3: styleTitle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.CornflowerBlue.Index; break; case -2: styleTitle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightYellow.Index; break; case -1: styleTitle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Rose.Index; break; case 0: styleTitle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Green.Index; break; case 1: styleTitle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.SkyBlue.Index; break; } styleTitle.FillPattern = FillPattern.SolidForeground; for (int j = 1; j <= gc.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday); j++) { byte[] rgb = new byte[3] { 192, 0, 0 }; sgb.GetRow(0).CreateCell(index + 6); sgb.GetRow(1).CreateCell(index + 6).SetCellValue(j); sgb.GetRow(0).GetCell(index + 6).CellStyle = styleTitle; if (dateTime.Year == DateTime.Now.Year && gc.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Monday) == j) { sgb.GetRow(1).GetCell(index + 6).CellStyle = styleToday; sgb.GetRow(1).GetCell(index + 6).CellStyle.VerticalAlignment = VerticalAlignment.Bottom; } else { sgb.GetRow(1).GetCell(index + 6).CellStyle = styleTitle; sgb.GetRow(1).GetCell(index + 6).CellStyle.VerticalAlignment = VerticalAlignment.Center; } sgb.GetRow(1).GetCell(index + 6).CellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; sgb.GetRow(1).GetCell(index + 6).CellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; sgb.GetRow(1).GetCell(index + 6).CellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; sgb.GetRow(1).GetCell(index + 6).CellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; //sgb.GetRow(0).GetCell(index + 6).CellStyle.SetFont(cs_content_Font);//将字体绑定到样式 //sgb.GetRow(1).GetCell(index + 6).CellStyle.SetFont(cs_content_Font);//将字体绑定到样式 index++; } CellRangeAddress cellRangeAddress = new CellRangeAddress(0, 0, index + 6 - gc.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday), (index + 5)); sgb.AddMergedRegion(cellRangeAddress); sgb.GetRow(0).GetCell(index + 6 - gc.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday)).SetCellValue(dateTime.Year); sgb.GetRow(0).GetCell(index + 6 - gc.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Monday)).CellStyle.Alignment = HorizontalAlignment.Center; } ICellStyle style = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 style.FillPattern = FillPattern.SolidForeground; ICellStyle styleA = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 styleA.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index; styleA.FillPattern = FillPattern.SolidForeground; ICellStyle styleB = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 styleB.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightBlue.Index; styleB.FillPattern = FillPattern.SolidForeground; ICellStyle styleC = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 styleC.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Indigo.Index; styleC.FillPattern = FillPattern.SolidForeground; ICellStyle styleD = (ICellStyle)hssfworkbook.CreateCellStyle(); //创建字体 styleD.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.LightBlue.Index; styleD.FillPattern = FillPattern.SolidForeground; if (tb.Rows.Count > 0) { var rowIndex = 2; for (int i = 0; i < tb.Rows.Count; i++) { if (sgb.GetRow(rowIndex) == null) sgb.CreateRow(rowIndex); //XSSFFont cs_content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 //cs_content_Font.FontHeightInPoints = 10; //字体大小 #region 列赋值 if (sgb.GetRow(rowIndex).GetCell(0) == null) sgb.GetRow(rowIndex).CreateCell(0); sgb.GetRow(rowIndex).GetCell(0).SetCellValue(tb.Rows[i]["ProjectControl_JobNo"].ToString()); //sgb.GetRow(rowIndex).GetCell(0).CellStyle.SetFont(cs_content_Font);//将字体绑定到样式 if (sgb.GetRow(rowIndex).GetCell(1) == null) sgb.GetRow(rowIndex).CreateCell(1); sgb.GetRow(rowIndex).GetCell(1).SetCellValue(tb.Rows[i]["ProjectControl_BUCode"].ToString()); if (sgb.GetRow(rowIndex).GetCell(2) == null) sgb.GetRow(rowIndex).CreateCell(2); sgb.GetRow(rowIndex).GetCell(2).SetCellValue(tb.Rows[i]["ProjectControl_JobType"].ToString()); if (sgb.GetRow(rowIndex).GetCell(3) == null) sgb.GetRow(rowIndex).CreateCell(3); sgb.GetRow(rowIndex).GetCell(3).SetCellValue(tb.Rows[i]["ProjectControl_JobTitle"].ToString()); if (sgb.GetRow(rowIndex).GetCell(4) == null) sgb.GetRow(rowIndex).CreateCell(4); sgb.GetRow(rowIndex).GetCell(4).SetCellValue(tb.Rows[i]["PM_General_Priority"].ToString()); if (sgb.GetRow(rowIndex).GetCell(5) == null) sgb.GetRow(rowIndex).CreateCell(5); sgb.GetRow(rowIndex).GetCell(5).SetCellValue(tb.Rows[i]["PM_General_Category"].ToString()); if (sgb.GetRow(rowIndex).GetCell(6) == null) sgb.GetRow(rowIndex).CreateCell(6); sgb.GetRow(rowIndex).GetCell(6).SetCellValue(tb.Rows[i]["Schedule"].ToString()); for (int j = 7; j < tb.Columns.Count - 6; j++) { if (sgb.GetRow(rowIndex).GetCell(j) == null) sgb.GetRow(rowIndex).CreateCell(j); sgb.GetRow(rowIndex).GetCell(j).SetCellValue(tb.Rows[i][j + 6].ToString()); switch (tb.Rows[i][j + 6].ToString()) { case "A": sgb.GetRow(rowIndex).GetCell(j).CellStyle = styleA; break; case "B": sgb.GetRow(rowIndex).GetCell(j).CellStyle = styleB; break; case "C": sgb.GetRow(rowIndex).GetCell(j).CellStyle = styleC; break; case "D": sgb.GetRow(rowIndex).GetCell(j).CellStyle = styleD; break; } } #endregion if ((int)((95 * (rowIndex - 1 + overNum + permitNum + prepipingNum)) / totalNum) > percent) { percent = (int)(100 * (rowIndex - 1 + overNum + permitNum + prepipingNum) / totalNum); } rowIndex++; } } #endregion #region Rolesview XSSFSheet rv = (XSSFSheet)hssfworkbook.GetSheet("Rolesview"); if (table.Rows.Count > 0) { var rowIndex = 2; for (int i = 0; i < table.Rows.Count; i++) { if (rv.GetRow(rowIndex) == null) rv.CreateRow(rowIndex); #region 列赋值 if (rv.GetRow(rowIndex).GetCell(0) == null) rv.GetRow(rowIndex).CreateCell(0); rv.GetRow(rowIndex).GetCell(0).SetCellValue(table.Rows[i]["ProjectControl_BUCode"].ToString()); if (rv.GetRow(rowIndex).GetCell(1) == null) rv.GetRow(rowIndex).CreateCell(1); rv.GetRow(rowIndex).GetCell(1).SetCellValue(table.Rows[i]["ProjectControl_JobNo"].ToString()); if (rv.GetRow(rowIndex).GetCell(2) == null) rv.GetRow(rowIndex).CreateCell(2); rv.GetRow(rowIndex).GetCell(2).SetCellValue(table.Rows[i]["ProjectControl_JobType"].ToString()); if (rv.GetRow(rowIndex).GetCell(3) == null) rv.GetRow(rowIndex).CreateCell(3); rv.GetRow(rowIndex).GetCell(3).SetCellValue(table.Rows[i]["ProjectControl_JobTitle"].ToString()); if (rv.GetRow(rowIndex).GetCell(4) == null) rv.GetRow(rowIndex).CreateCell(4); rv.GetRow(rowIndex).GetCell(4).SetCellValue(table.Rows[i]["ProjectControl_JobStatus"].ToString()); if (rv.GetRow(rowIndex).GetCell(5) == null) rv.GetRow(rowIndex).CreateCell(5); rv.GetRow(rowIndex).GetCell(5).SetCellValue(table.Rows[i]["PM_General_Priority"].ToString()); if (rv.GetRow(rowIndex).GetCell(6) == null) rv.GetRow(rowIndex).CreateCell(6); rv.GetRow(rowIndex).GetCell(6).SetCellValue(table.Rows[i]["ProjectManager"].ToString()); if (rv.GetRow(rowIndex).GetCell(7) == null) rv.GetRow(rowIndex).CreateCell(7); rv.GetRow(rowIndex).GetCell(7).SetCellValue(table.Rows[i]["Proc_Designer"].ToString()); if (rv.GetRow(rowIndex).GetCell(8) == null) rv.GetRow(rowIndex).CreateCell(8); rv.GetRow(rowIndex).GetCell(8).SetCellValue(table.Rows[i]["Proc_Checker"].ToString()); if (rv.GetRow(rowIndex).GetCell(9) == null) rv.GetRow(rowIndex).CreateCell(9); rv.GetRow(rowIndex).GetCell(9).SetCellValue(table.Rows[i]["Proc_Approvers"].ToString()); if (rv.GetRow(rowIndex).GetCell(10) == null) rv.GetRow(rowIndex).CreateCell(10); rv.GetRow(rowIndex).GetCell(10).SetCellValue(table.Rows[i]["ME_Designer"].ToString()); if (rv.GetRow(rowIndex).GetCell(11) == null) rv.GetRow(rowIndex).CreateCell(11); rv.GetRow(rowIndex).GetCell(11).SetCellValue(table.Rows[i]["ME_Checker"].ToString()); if (rv.GetRow(rowIndex).GetCell(12) == null) rv.GetRow(rowIndex).CreateCell(12); rv.GetRow(rowIndex).GetCell(12).SetCellValue(table.Rows[i]["ME_Approvers"].ToString()); if (rv.GetRow(rowIndex).GetCell(13) == null) rv.GetRow(rowIndex).CreateCell(13); rv.GetRow(rowIndex).GetCell(13).SetCellValue(table.Rows[i]["PluFF_Designer"].ToString()); if (rv.GetRow(rowIndex).GetCell(14) == null) rv.GetRow(rowIndex).CreateCell(14); rv.GetRow(rowIndex).GetCell(14).SetCellValue(table.Rows[i]["PluFF_Checker"].ToString()); if (rv.GetRow(rowIndex).GetCell(15) == null) rv.GetRow(rowIndex).CreateCell(15); rv.GetRow(rowIndex).GetCell(15).SetCellValue(table.Rows[i]["PluFF_Approvers"].ToString()); if (rv.GetRow(rowIndex).GetCell(16) == null) rv.GetRow(rowIndex).CreateCell(16); rv.GetRow(rowIndex).GetCell(16).SetCellValue(table.Rows[i]["Piping_Designer"].ToString()); if (rv.GetRow(rowIndex).GetCell(17) == null) rv.GetRow(rowIndex).CreateCell(17); rv.GetRow(rowIndex).GetCell(17).SetCellValue(table.Rows[i]["Piping_Checker"].ToString()); if (rv.GetRow(rowIndex).GetCell(18) == null) rv.GetRow(rowIndex).CreateCell(18); rv.GetRow(rowIndex).GetCell(18).SetCellValue(table.Rows[i]["Piping_Approvers"].ToString()); if (rv.GetRow(rowIndex).GetCell(19) == null) rv.GetRow(rowIndex).CreateCell(19); rv.GetRow(rowIndex).GetCell(19).SetCellValue(table.Rows[i]["Ins_Designer"].ToString()); if (rv.GetRow(rowIndex).GetCell(20) == null) rv.GetRow(rowIndex).CreateCell(20); rv.GetRow(rowIndex).GetCell(20).SetCellValue(table.Rows[i]["Ins_Checker"].ToString()); if (rv.GetRow(rowIndex).GetCell(21) == null) rv.GetRow(rowIndex).CreateCell(21); rv.GetRow(rowIndex).GetCell(21).SetCellValue(table.Rows[i]["Ins_Approvers"].ToString()); if (rv.GetRow(rowIndex).GetCell(22) == null) rv.GetRow(rowIndex).CreateCell(22); rv.GetRow(rowIndex).GetCell(22).SetCellValue(table.Rows[i]["Ele_Designer"].ToString()); if (rv.GetRow(rowIndex).GetCell(23) == null) rv.GetRow(rowIndex).CreateCell(23); rv.GetRow(rowIndex).GetCell(23).SetCellValue(table.Rows[i]["Ele_Checker"].ToString()); if (rv.GetRow(rowIndex).GetCell(24) == null) rv.GetRow(rowIndex).CreateCell(24); rv.GetRow(rowIndex).GetCell(24).SetCellValue(table.Rows[i]["Ele_Approvers"].ToString()); if (rv.GetRow(rowIndex).GetCell(25) == null) rv.GetRow(rowIndex).CreateCell(25); rv.GetRow(rowIndex).GetCell(25).SetCellValue(table.Rows[i]["Civ_Designer"].ToString()); if (rv.GetRow(rowIndex).GetCell(26) == null) rv.GetRow(rowIndex).CreateCell(26); rv.GetRow(rowIndex).GetCell(26).SetCellValue(table.Rows[i]["Civ_Checker"].ToString()); if (rv.GetRow(rowIndex).GetCell(27) == null) rv.GetRow(rowIndex).CreateCell(27); rv.GetRow(rowIndex).GetCell(27).SetCellValue(table.Rows[i]["Civ_Approvers"].ToString()); if (rv.GetRow(rowIndex).GetCell(28) == null) rv.GetRow(rowIndex).CreateCell(28); rv.GetRow(rowIndex).GetCell(28).SetCellValue(table.Rows[i]["MP_Designer"].ToString()); if (rv.GetRow(rowIndex).GetCell(29) == null) rv.GetRow(rowIndex).CreateCell(29); rv.GetRow(rowIndex).GetCell(29).SetCellValue(table.Rows[i]["MP_Checker"].ToString()); if (rv.GetRow(rowIndex).GetCell(30) == null) rv.GetRow(rowIndex).CreateCell(30); rv.GetRow(rowIndex).GetCell(30).SetCellValue(table.Rows[i]["MP_Approvers"].ToString()); #endregion if ((int)((95 * (rowIndex - 1 + overNum + permitNum + prepipingNum + ganttBarNum)) / totalNum) > percent) { percent = (int)(100 * (rowIndex - 1 + overNum + permitNum + prepipingNum + ganttBarNum) / totalNum); } rowIndex++; } } #endregion overview.ForceFormulaRecalculation = true; pg.ForceFormulaRecalculation = true; ppv.ForceFormulaRecalculation = true; sgb.ForceFormulaRecalculation = true; rv.ForceFormulaRecalculation = true; using (FileStream filess = File.OpenWrite(ReportFileName)) { hssfworkbook.Write(filess); hssfworkbook.Close(); filess.Flush(); filess.Close(); } percent = 100; url = ReportFileName.Replace(Server.MapPath("~/"), ""); //using (FileStream filess = File.OpenWrite(ReportFileName)) //{ // hssfworkbook.Write(filess); //} //FileInfo filet = new FileInfo(ReportFileName); //Response.Clear(); //Response.Charset = "GB2312"; //Response.ContentEncoding = System.Text.Encoding.UTF8; //// 添加头信息,为"文件下载/另存为"对话框指定默认文件名 //Response.AddHeader("Content-Disposition", "attachment; filename=P32_Roles_Report_" + Server.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx")); //// 添加头信息,指定文件大小,让浏览器能够显示下载进度 //Response.AddHeader("Content-Length", filet.Length.ToString()); //// 指定返回的是一个不能被客户端读取的流,必须被下载 //Response.ContentType = "application/ms-excel"; //// 把文件流发送到客户端 //Response.WriteFile(filet.FullName); //// 停止页面的执行 //Response.End(); } #endregion #region 权限设置 /// /// 菜单按钮权限 /// private void GetButtonPower() { var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.RolesReportMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnOut)) { this.btnExport.Hidden = false; } } } #endregion } }