450 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			450 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			C#
		
	
	
	
| using BLL;
 | ||
| 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.IO;
 | ||
| using System.Linq;
 | ||
| using System.Web;
 | ||
| using System.Web.UI;
 | ||
| 
 | ||
| namespace FineUIPro.Web.TestRun.Feeding
 | ||
| {
 | ||
|     public partial class FeedingRunApplication : PageBase
 | ||
|     {
 | ||
|         protected void Page_Load(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (!IsPostBack)
 | ||
|             {
 | ||
|                 InitTreeMenu();
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         #region 数加载
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 加载树
 | ||
|         /// </summary>
 | ||
|         private void InitTreeMenu()
 | ||
|         {
 | ||
|             this.tvControlItem.Nodes.Clear();
 | ||
|             TreeNode rootNode = new TreeNode();
 | ||
|             rootNode.Text = "检查表";
 | ||
|             rootNode.NodeID = "0";
 | ||
|             rootNode.Expanded = true;
 | ||
|             rootNode.ToolTip = "";
 | ||
|             rootNode.EnableClickEvent = true;
 | ||
|             this.tvControlItem.Nodes.Add(rootNode);
 | ||
|             var inspectTerms = Funs.DB.FeedingRun_SubInspectTerm.Where(x => x.InspectIsClose == 1).ToList();
 | ||
|             if (inspectTerms.Count == 0) return;
 | ||
|             var subInstallationIds = inspectTerms.ConvertAll(x => x.InstallationId);
 | ||
|             var list = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 1 && subInstallationIds.Contains(x.PreRunId)).OrderBy(a => a.Sort);
 | ||
|             if (list.Count() > 0)
 | ||
|             {
 | ||
|                 foreach (var item in list)
 | ||
|                 {
 | ||
|                     TreeNode rootOneNode = new TreeNode();
 | ||
|                     rootOneNode.NodeID = item.PreRunId;
 | ||
|                     rootOneNode.Text = item.PreRunName;
 | ||
|                     rootOneNode.ToolTip = item.PreRunName;
 | ||
|                     rootOneNode.CommandName = "";
 | ||
|                     rootOneNode.EnableClickEvent = true;
 | ||
|                     rootOneNode.EnableExpandEvent = false;
 | ||
|                     rootNode.Nodes.Add(rootOneNode);
 | ||
|                     rootOneNode.Expanded = true;
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 树点击
 | ||
|         /// </summary>
 | ||
|         protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
 | ||
|         {
 | ||
|             BindGrid();
 | ||
|         }
 | ||
| 
 | ||
|         #endregion
 | ||
| 
 | ||
|         #region 数据绑定
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 绑定数据
 | ||
|         /// </summary>
 | ||
|         public void BindGrid()
 | ||
|         {
 | ||
|             List<SqlParameter> listStr = new List<SqlParameter>();
 | ||
|             string sqlStr = $"select  a.SubInspectId,a.ProjectId,a.InstallationId,a.DriverCharge,c.UserName as DriverChargeName,a.DrivingManager,d.UserName as DrivingManagerName,a.ProjectManager,e.UserName as ProjectManagerName,a.WanderIsComplete,a.WanderCompleteData,a.IsUnifyWanderAbout,a.UnifyWanderAboutData,a.InspectIsClose,a.InspectCloseData,b.ProjectCode,b.ProjectName from FeedingRun_SubInspectTerm as a inner join Base_Project as b on a.ProjectId=b.ProjectId inner join Sys_User as c on c.UserId=a.DriverCharge inner join Sys_User as d on d.UserId=a.DrivingManager inner join Sys_User as e on e.UserId=a.ProjectManager where a.InspectIsClose=1 and a.ProjectId=@projectid ";
 | ||
|             listStr.Add(new SqlParameter("@projectid", this.CurrUser.LoginProjectId));
 | ||
|             if(!string.IsNullOrWhiteSpace(this.tvControlItem.SelectedNodeID))
 | ||
|             {
 | ||
|                 sqlStr += $"and a.InstallationId=@InstallationId ";
 | ||
|                 listStr.Add(new SqlParameter("@InstallationId", this.tvControlItem.SelectedNodeID));
 | ||
|             }
 | ||
|             sqlStr += " order by a.InspectCloseData desc";
 | ||
|             SqlParameter[] parameter = listStr.ToArray();
 | ||
|             DataTable tb = SQLHelper.GetDataTableRunText(sqlStr, parameter);
 | ||
|             Grid1.RecordCount = tb.Rows.Count;
 | ||
|             var table = this.GetPagedDataTable(Grid1, tb);
 | ||
|             Grid1.DataSource = table;
 | ||
|             Grid1.DataBind();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 分页
 | ||
|         /// </summary>
 | ||
|         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | ||
|         {
 | ||
|             Grid1.PageIndex = e.NewPageIndex;
 | ||
|             BindGrid();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 分页下拉框
 | ||
|         /// </summary>
 | ||
|         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
 | ||
|             BindGrid();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 排序
 | ||
|         /// </summary>
 | ||
|         protected void Grid1_Sort(object sender, GridSortEventArgs e)
 | ||
|         {
 | ||
|             BindGrid();
 | ||
|         }
 | ||
| 
 | ||
|         #endregion
 | ||
| 
 | ||
|         #region 按钮和事件
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 查询
 | ||
|         /// </summary>
 | ||
|         protected void btnQuery_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             BindGrid();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 导出投料试车申请表
 | ||
|         /// </summary>
 | ||
|         protected void btnExport_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             //string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
 | ||
|             ////导出文件
 | ||
|             //string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
 | ||
|             //if (!Directory.Exists(filePath))
 | ||
|             //{
 | ||
|             //    Directory.CreateDirectory(filePath);
 | ||
|             //}
 | ||
|             //string ReportFileName = filePath + "投料试车申请.xlsx";
 | ||
|             ////获取工作包检查表
 | ||
|             //var termData = from a in Funs.DB.FeedingRun_SubInspectTerm
 | ||
|             //               join b in Funs.DB.Base_Project on a.ProjectId equals b.ProjectId
 | ||
|             //               join zz in Funs.DB.PreRun_SysDevice on a.InstallationId equals zz.PreRunId//装置
 | ||
|             //               select new { a.SubInspectId, a.ProjectId, b.ProjectName, b.ShortName, b.ProjectCode, a.InstallationId, a.DriverCharge, a.DrivingManager, a.ProjectManager, a.InspectionIsAllPass, a.DriverChargeIsAllPass, a.DrivingManagerIsAllPass, a.ProjectManagerIsAllPass, a.InspectTime, a.AddUser, a.AddTime, zzName = zz.PreRunName };
 | ||
|             //if (termData != null)
 | ||
|             //{
 | ||
|             //    var termModel = termData.FirstOrDefault();
 | ||
|             //    //获取工作包检查项表
 | ||
|             //    var termItems = Funs.DB.FeedingRun_SubInspectTermItem.Where(x => x.SubInspectId == this.SubInspectId).OrderBy(x => x.Sort).ToList();
 | ||
|             //    int rowIndex = 0;
 | ||
|             //    XSSFWorkbook hssfworkbook = new XSSFWorkbook();
 | ||
|             //    XSSFSheet ws = (XSSFSheet)hssfworkbook.CreateSheet("投料试车申请");
 | ||
| 
 | ||
|             //    #region 列宽
 | ||
| 
 | ||
|             //    ws.SetColumnWidth(0, (7 * 256));
 | ||
|             //    ws.SetColumnWidth(1, (4 * 256));
 | ||
|             //    ws.SetColumnWidth(2, (4 * 256));
 | ||
|             //    ws.SetColumnWidth(3, (4 * 256));
 | ||
|             //    ws.SetColumnWidth(4, (10 * 256));
 | ||
|             //    ws.SetColumnWidth(5, (10 * 256));
 | ||
|             //    ws.SetColumnWidth(6, (10 * 256));
 | ||
|             //    ws.SetColumnWidth(7, (10 * 256));
 | ||
|             //    ws.SetColumnWidth(8, (3 * 256));
 | ||
|             //    ws.SetColumnWidth(9, (3 * 256));
 | ||
|             //    ws.SetColumnWidth(10, (3 * 256));
 | ||
|             //    ws.SetColumnWidth(11, (3 * 256));
 | ||
|             //    ws.SetColumnWidth(12, (3 * 256));
 | ||
|             //    ws.SetColumnWidth(13, (3 * 256));
 | ||
|             //    ws.SetColumnWidth(14, (3 * 256));
 | ||
|             //    ws.SetColumnWidth(15, (3 * 256));
 | ||
|             //    ws.SetColumnWidth(16, (3 * 256));
 | ||
|             //    ws.SetColumnWidth(17, (3 * 256));
 | ||
| 
 | ||
|             //    #endregion
 | ||
| 
 | ||
|             //    #region 样式
 | ||
|             //    //头部样式居中
 | ||
|             //    ICellStyle titleStyle = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 14, true, true);
 | ||
|             //    //头部样式靠左
 | ||
|             //    ICellStyle leftTitleStyle = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Left, 14, true, true);
 | ||
|             //    //公共样式
 | ||
|             //    ICellStyle style = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10.5, true);
 | ||
|             //    //公共样式靠左
 | ||
|             //    ICellStyle leftStyle = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Left, 10.5, true);
 | ||
|             //    //公共样式靠左上对其
 | ||
|             //    ICellStyle leftTopStyle = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Top, HorizontalAlignment.Left, 10.5, true);
 | ||
|             //    //公共样式加粗
 | ||
|             //    ICellStyle styleBold = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10.5, true, true);
 | ||
| 
 | ||
|             //    #endregion
 | ||
| 
 | ||
|             //    #region 头部
 | ||
| 
 | ||
|             //    ws = ExcelCreateRowTitle(ws, hssfworkbook, style, rowIndex, rowIndex + 5, 0, 17);
 | ||
|             //    //行1
 | ||
|             //    var region = new CellRangeAddress(rowIndex, rowIndex + 2, 0, 0);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    byte[] bytes = File.ReadAllBytes(Server.MapPath("~/") + "Images\\Template.png");
 | ||
|             //    int pictureIdx = hssfworkbook.AddPicture(bytes, PictureType.JPEG);
 | ||
|             //    IDrawing patriarch = ws.CreateDrawingPatriarch();
 | ||
|             //    IClientAnchor anchor = patriarch.CreateAnchor(0, 0, 0, 0, 0, rowIndex, 1, rowIndex + 2);
 | ||
|             //    IPicture pict = patriarch.CreatePicture(anchor, pictureIdx);
 | ||
|             //    //pict.Resize();
 | ||
|             //    region = new CellRangeAddress(rowIndex, rowIndex + 2, 1, 3);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex).GetCell(1).SetCellValue("中国五环工程有限公司");
 | ||
|             //    ws.GetRow(rowIndex).GetCell(1).CellStyle =
 | ||
|             //    ws.GetRow(rowIndex).GetCell(2).CellStyle =
 | ||
|             //    ws.GetRow(rowIndex).GetCell(3).CellStyle = leftTitleStyle;
 | ||
|             //    region = new CellRangeAddress(rowIndex, rowIndex, 4, 7);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex).GetCell(4).SetCellValue(termModel.ProjectName);
 | ||
|             //    ws.GetRow(rowIndex).GetCell(4).CellStyle = style;
 | ||
|             //    region = new CellRangeAddress(rowIndex, rowIndex, 8, 12);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex).GetCell(8).SetCellValue("项目号");
 | ||
|             //    ws.GetRow(rowIndex).GetCell(8).CellStyle = style;
 | ||
|             //    region = new CellRangeAddress(rowIndex, rowIndex, 13, 17);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex).GetCell(13).SetCellValue(termModel.ProjectCode);
 | ||
|             //    ws.GetRow(rowIndex).GetCell(13).CellStyle = style;
 | ||
|             //    region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 4, 7);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(4).SetCellValue($"({termModel.zzName})");
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(4).CellStyle = style;
 | ||
|             //    region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 8, 12);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(8).SetCellValue("(文件号)");
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(8).CellStyle = style;
 | ||
|             //    region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 13, 17);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(13).SetCellValue("");
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(13).CellStyle = style;
 | ||
|             //    region = new CellRangeAddress(rowIndex + 2, rowIndex + 2, 4, 7);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 2).GetCell(4).SetCellValue($"投料试车条件检查表");
 | ||
|             //    ws.GetRow(rowIndex + 2).GetCell(4).CellStyle = titleStyle;
 | ||
|             //    region = new CellRangeAddress(rowIndex + 2, rowIndex + 2, 8, 12);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 2).GetCell(8).SetCellValue("第   1    页");
 | ||
|             //    ws.GetRow(rowIndex + 2).GetCell(8).CellStyle = style;
 | ||
|             //    region = new CellRangeAddress(rowIndex + 2, rowIndex + 2, 13, 17);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 2).GetCell(13).SetCellValue("共    1     页");
 | ||
|             //    ws.GetRow(rowIndex + 2).GetCell(13).CellStyle = style;
 | ||
|             //    //行4,行5
 | ||
|             //    region = new CellRangeAddress(rowIndex + 3, rowIndex + 4, 0, 2);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 3).GetCell(0).CellStyle = style;
 | ||
|             //    ws.GetRow(rowIndex + 3).GetCell(0).SetCellValue("");
 | ||
|             //    region = new CellRangeAddress(rowIndex + 3, rowIndex + 4, 3, 11);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 3).GetCell(3).CellStyle = leftStyle;
 | ||
|             //    ws.GetRow(rowIndex + 3).GetCell(3).SetCellValue("");
 | ||
|             //    region = new CellRangeAddress(rowIndex + 3, rowIndex + 3, 12, 17);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 3).GetCell(12).CellStyle = style;
 | ||
|             //    ws.GetRow(rowIndex + 3).GetCell(12).SetCellValue("检查日期");
 | ||
|             //    region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 12, 17);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 4).GetCell(12).CellStyle = style;
 | ||
|             //    ws.GetRow(rowIndex + 4).GetCell(12).SetCellValue(DateTime.Now.ToString("yyyy年MM月dd日"));
 | ||
|             //    //行6
 | ||
|             //    ws.GetRow(rowIndex + 5).GetCell(0).CellStyle = styleBold;
 | ||
|             //    ws.GetRow(rowIndex + 5).GetCell(0).SetCellValue("序号");
 | ||
|             //    region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 1, 7);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 5).GetCell(1).CellStyle = styleBold;
 | ||
|             //    ws.GetRow(rowIndex + 5).GetCell(1).SetCellValue("检查项目");
 | ||
|             //    region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 8, 12);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 5).GetCell(8).CellStyle = styleBold;
 | ||
|             //    ws.GetRow(rowIndex + 5).GetCell(8).SetCellValue("结果");
 | ||
|             //    region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 13, 17);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 5).GetCell(13).CellStyle = styleBold;
 | ||
|             //    ws.GetRow(rowIndex + 5).GetCell(13).SetCellValue("备注");
 | ||
| 
 | ||
|             //    #endregion
 | ||
| 
 | ||
|             //    #region 表格
 | ||
| 
 | ||
|             //    var start = rowIndex + 6;
 | ||
|             //    var end = rowIndex + 5 + termItems.Count;
 | ||
| 
 | ||
|             //    ws = ExcelCreateRowTitle(ws, hssfworkbook, style, start, end, 0, 17);
 | ||
| 
 | ||
|             //    //合并单元格
 | ||
|             //    for (int hb = start; hb <= end; hb++)
 | ||
|             //    {
 | ||
|             //        region = new CellRangeAddress(hb, hb, 1, 7);
 | ||
|             //        ws.AddMergedRegion(region);
 | ||
|             //        region = new CellRangeAddress(hb, hb, 8, 12);
 | ||
|             //        ws.AddMergedRegion(region);
 | ||
|             //        region = new CellRangeAddress(hb, hb, 13, 17);
 | ||
|             //        ws.AddMergedRegion(region);
 | ||
|             //    }
 | ||
| 
 | ||
|             //    //数据
 | ||
|             //    int num = 1;
 | ||
|             //    var dataIndex = 6;
 | ||
|             //    foreach (var item in termItems)
 | ||
|             //    {
 | ||
|             //        //序号
 | ||
|             //        ws.GetRow(dataIndex).GetCell(0).SetCellValue(num);
 | ||
|             //        //检查项目
 | ||
|             //        ws.GetRow(dataIndex).GetCell(1).SetCellValue(item.WorkInspectName);
 | ||
|             //        ws.GetRow(dataIndex).GetCell(1).CellStyle = leftStyle;
 | ||
|             //        //结果
 | ||
|             //        ws.GetRow(dataIndex).GetCell(8).SetCellValue("");
 | ||
|             //        //备注
 | ||
|             //        ws.GetRow(dataIndex).GetCell(13).SetCellValue("");
 | ||
|             //        dataIndex++;
 | ||
|             //        num++;
 | ||
|             //    }
 | ||
|             //    rowIndex = start + termItems.Count;
 | ||
| 
 | ||
|             //    #endregion
 | ||
| 
 | ||
|             //    #region 尾部
 | ||
| 
 | ||
|             //    ws = ExcelCreateRowTitle(ws, hssfworkbook, style, rowIndex, rowIndex, 0, 17, 100);
 | ||
|             //    //行1
 | ||
|             //    ws.GetRow(rowIndex).GetCell(0).SetCellValue("结论");
 | ||
|             //    region = new CellRangeAddress(rowIndex, rowIndex, 1, 17);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex).GetCell(1).SetCellValue("是否同意进行(包括整改意见):");
 | ||
|             //    ws.GetRow(rowIndex).GetCell(1).CellStyle = leftTopStyle;
 | ||
|             //    //行2
 | ||
|             //    ws = ExcelCreateRowTitle(ws, hssfworkbook, style, rowIndex + 1, rowIndex + 1, 0, 17, 80);
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(0).SetCellValue("检查人员");
 | ||
|             //    region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 1, 4);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(1).SetCellValue("施工单位:");
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(1).CellStyle = leftTopStyle;
 | ||
|             //    region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 5, 6);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(5).SetCellValue("装置开车负责人:");
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(5).CellStyle = leftTopStyle;
 | ||
|             //    region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 7, 11);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(7).SetCellValue("开车经理:");
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(7).CellStyle = leftTopStyle;
 | ||
|             //    region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 12, 17);
 | ||
|             //    ws.AddMergedRegion(region);
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(12).SetCellValue("项目经理:");
 | ||
|             //    ws.GetRow(rowIndex + 1).GetCell(12).CellStyle = leftTopStyle;
 | ||
| 
 | ||
|             //    #endregion
 | ||
| 
 | ||
|             //    ws.PrintSetup.Landscape = false;
 | ||
|             //    ws.PrintSetup.PaperSize = 9;
 | ||
|             //    ws.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=" + Server.UrlEncode("投料试车申请.xlsx"));
 | ||
|             //    // 添加头信息,指定文件大小,让浏览器能够显示下载进度
 | ||
|             //    Response.AddHeader("Content-Length", filet.Length.ToString());
 | ||
|             //    // 指定返回的是一个不能被客户端读取的流,必须被下载
 | ||
|             //    Response.ContentType = "application/ms-excel";
 | ||
|             //    // 把文件流发送到客户端
 | ||
|             //    Response.WriteFile(filet.FullName);
 | ||
|             //    // 停止页面的执行
 | ||
|             //    Response.End();
 | ||
|             //}
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 右击导出投料试车申请表
 | ||
|         /// </summary>
 | ||
|         protected void btnMenuExport_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             btnExport_Click(null, null);
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 双击事件
 | ||
|         /// </summary>
 | ||
|         protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
 | ||
|         {
 | ||
|             btnExport_Click(null, null);
 | ||
|         }
 | ||
| 
 | ||
|         #endregion
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         #region 私有方法
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 创建样式
 | ||
|         /// </summary>
 | ||
|         /// <returns></returns>
 | ||
|         public static ICellStyle SetExcelStyle(XSSFWorkbook wb, BorderStyle Bottom, BorderStyle Left, BorderStyle Right, BorderStyle Top, VerticalAlignment VerAig, HorizontalAlignment HorAig, double FontSize, bool WrapText = true, bool Bold = false, string FontName = "宋体")
 | ||
|         {
 | ||
|             ICellStyle style = wb.CreateCellStyle();
 | ||
|             style.BorderBottom = Bottom;
 | ||
|             style.BorderLeft = Left;
 | ||
|             style.BorderRight = Right;
 | ||
|             style.BorderTop = Top;
 | ||
|             style.VerticalAlignment = VerAig;
 | ||
|             style.Alignment = HorAig;
 | ||
|             IFont font = wb.CreateFont();
 | ||
|             font.FontHeightInPoints = FontSize;
 | ||
|             font.IsBold = Bold;
 | ||
|             font.FontName = FontName;
 | ||
|             style.SetFont(font);
 | ||
|             style.WrapText = WrapText;
 | ||
|             return style;
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 创建头部
 | ||
|         /// </summary>
 | ||
|         /// <returns></returns>
 | ||
|         private XSSFSheet ExcelCreateRowTitle(XSSFSheet ws, XSSFWorkbook hssfworkbook, ICellStyle style, int sRows, int eRows, int cStart, int cEnd, float height = 21)
 | ||
|         {
 | ||
|             for (int i = sRows; i <= eRows; i++)
 | ||
|             {
 | ||
|                 ws.CreateRow(i);
 | ||
|                 ws.GetRow(i).HeightInPoints = height;
 | ||
|                 for (int j = cStart; j <= cEnd; j++)
 | ||
|                 {
 | ||
|                     ws.GetRow(i).CreateCell(j);
 | ||
|                     ws.GetRow(i).CreateCell(j).CellStyle = style;
 | ||
|                 }
 | ||
|             }
 | ||
|             return ws;
 | ||
|         }
 | ||
| 
 | ||
|         #endregion
 | ||
| 
 | ||
|     }
 | ||
| } |