update weld day report

This commit is contained in:
jackchenyang 2024-05-09 18:41:24 +08:00
parent 5b8aa9929e
commit b0312d603e
15 changed files with 277 additions and 198 deletions

View File

@ -15,9 +15,8 @@
<VisualStudio> <VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties> <WebProjectProperties>
<StartPageUrl> <StartPageUrl>Login.aspx</StartPageUrl>
</StartPageUrl> <StartAction>SpecificPage</StartAction>
<StartAction>CurrentPage</StartAction>
<AspNetDebugging>True</AspNetDebugging> <AspNetDebugging>True</AspNetDebugging>
<SilverlightDebugging>False</SilverlightDebugging> <SilverlightDebugging>False</SilverlightDebugging>
<NativeDebugging>False</NativeDebugging> <NativeDebugging>False</NativeDebugging>

View File

@ -2946,29 +2946,33 @@ namespace FineUIPro.Web.WeldingProcess.TestPackageManage
private void template21(XSSFWorkbook hssfworkbook, XSSFSheet ws) private void template21(XSSFWorkbook hssfworkbook, XSSFSheet ws)
{ {
#region #region
var style = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 11, true, false, "宋体"); var style = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 15, true, false, "宋体");
var styleTwo = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Left, 9.5, true, false, "宋体");
var styleThree = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 9.5, true, false, "宋体");
var style4 = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 10.5, true, false, "宋体");
int rowIndex = 0; int rowIndex = 0;
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex, rowIndex + 3, style, 0, 14, true); ws = ExcelCreateRow(ws, hssfworkbook, rowIndex, rowIndex + 3, style, 0, 14, true);
//设置列宽 //设置列宽
ws.SetColumnWidth(0, 17 * 256); ws.SetColumnWidth(0, 18 * 256);
ws.SetColumnWidth(1, 12 * 256); ws.SetColumnWidth(1, 9 * 256);
ws.SetColumnWidth(2, 10 * 256); ws.SetColumnWidth(2, 6 * 256);
ws.SetColumnWidth(3, 15 * 256); ws.SetColumnWidth(3, 12 * 256);
ws.SetColumnWidth(4, 17 * 256); ws.SetColumnWidth(4, 18 * 256);
ws.SetColumnWidth(5, 14 * 256); ws.SetColumnWidth(5, 19 * 256);
ws.SetColumnWidth(6, 12 * 256); ws.SetColumnWidth(6, 13 * 256);
ws.SetColumnWidth(7, 15 * 256); ws.SetColumnWidth(7, 13 * 256);
ws.SetColumnWidth(8, 12 * 256); ws.SetColumnWidth(8, 14 * 256);
ws.SetColumnWidth(9, 13 * 256); ws.SetColumnWidth(9, 13 * 256);
ws.SetColumnWidth(10, 12 * 256); ws.SetColumnWidth(10, 13 * 256);
ws.SetColumnWidth(11, 12 * 256); ws.SetColumnWidth(11, 10 * 256);
ws.SetColumnWidth(12, 17 * 256); ws.SetColumnWidth(12, 16 * 256);
ws.SetColumnWidth(13, 12 * 256); ws.SetColumnWidth(13, 14 * 256);
ws.SetColumnWidth(14, 12 * 256); ws.SetColumnWidth(14, 19 * 256);
ws.AddMergedRegion(new CellRangeAddress(0, 3, 0, 1)); ws.AddMergedRegion(new CellRangeAddress(0, 3, 0, 1));
ws.GetRow(rowIndex).GetCell(0).SetCellValue("SH/T 3503-J415-1"); ws.GetRow(rowIndex).GetCell(0).SetCellValue("SH/T 3503-J415-1");
ws.GetRow(rowIndex).GetCell(0).CellStyle = styleThree;
ws.AddMergedRegion(new CellRangeAddress(0, 3, 2, 10)); ws.AddMergedRegion(new CellRangeAddress(0, 3, 2, 10));
ws.GetRow(rowIndex).GetCell(2).SetCellValue("管道焊接工作记录\r\nPiping Welding Record"); ws.GetRow(rowIndex).GetCell(2).SetCellValue("管道焊接工作记录\r\nPiping Welding Record");
@ -2982,6 +2986,10 @@ namespace FineUIPro.Web.WeldingProcess.TestPackageManage
ws.GetRow(rowIndex + 1).GetCell(11).SetCellValue("Project Name:BASF (Guangdong) Integrated Project"); ws.GetRow(rowIndex + 1).GetCell(11).SetCellValue("Project Name:BASF (Guangdong) Integrated Project");
ws.GetRow(rowIndex + 2).GetCell(11).SetCellValue("单位工程名称:埋地消防系统"); ws.GetRow(rowIndex + 2).GetCell(11).SetCellValue("单位工程名称:埋地消防系统");
ws.GetRow(rowIndex + 3).GetCell(11).SetCellValue("Unit NameFW"); ws.GetRow(rowIndex + 3).GetCell(11).SetCellValue("Unit NameFW");
ws.GetRow(rowIndex).GetCell(11).CellStyle = ws.GetRow(rowIndex + 1).GetCell(11).CellStyle = ws.GetRow(rowIndex + 2).GetCell(11).CellStyle = ws.GetRow(rowIndex + 3).GetCell(11).CellStyle = styleTwo;
ws.GetRow(rowIndex).Height = ws.GetRow(rowIndex + 1).Height = ws.GetRow(rowIndex + 2).Height = ws.GetRow(rowIndex + 3).Height = 25 * 20;
@ -2989,10 +2997,10 @@ namespace FineUIPro.Web.WeldingProcess.TestPackageManage
#endregion #endregion
#region #region
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 4, rowIndex + 5, style, 0, 14, true); ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 4, rowIndex + 5, style4, 0, 14, true);
ws.GetRow(rowIndex + 4).Height = 30 * 20; ws.GetRow(rowIndex + 4).Height = 25 * 20;
ws.GetRow(rowIndex + 5).Height = 45 * 20; ws.GetRow(rowIndex + 5).Height = 25 * 20;
//设置表头部分 //设置表头部分
ws.AddMergedRegion(new CellRangeAddress(4, 5, 0, 0)); ws.AddMergedRegion(new CellRangeAddress(4, 5, 0, 0));
ws.GetRow(rowIndex + 4).GetCell(0).SetCellValue("管道编号/单线号\r\nPiping No./Line No"); ws.GetRow(rowIndex + 4).GetCell(0).SetCellValue("管道编号/单线号\r\nPiping No./Line No");
@ -3003,7 +3011,7 @@ namespace FineUIPro.Web.WeldingProcess.TestPackageManage
ws.AddMergedRegion(new CellRangeAddress(4, 5, 4, 4)); ws.AddMergedRegion(new CellRangeAddress(4, 5, 4, 4));
ws.GetRow(rowIndex + 4).GetCell(4).SetCellValue("焊工代号\r\nWelder's Stamp No."); ws.GetRow(rowIndex + 4).GetCell(4).SetCellValue("焊工代号\r\nWelder's Stamp No.");
ws.AddMergedRegion(new CellRangeAddress(4, 5, 5, 5)); ws.AddMergedRegion(new CellRangeAddress(4, 5, 5, 5));
ws.GetRow(rowIndex + 4).GetCell(5).SetCellValue("规格mm\r\nSpecification\r\nmm"); ws.GetRow(rowIndex + 4).GetCell(5).SetCellValue("规格mm\r\nSpecification mm");
ws.AddMergedRegion(new CellRangeAddress(4, 5, 6, 6)); ws.AddMergedRegion(new CellRangeAddress(4, 5, 6, 6));
ws.GetRow(rowIndex + 4).GetCell(6).SetCellValue("材质\r\nMaterial"); ws.GetRow(rowIndex + 4).GetCell(6).SetCellValue("材质\r\nMaterial");
ws.AddMergedRegion(new CellRangeAddress(4, 5, 7, 7)); ws.AddMergedRegion(new CellRangeAddress(4, 5, 7, 7));
@ -3019,6 +3027,13 @@ namespace FineUIPro.Web.WeldingProcess.TestPackageManage
ws.AddMergedRegion(new CellRangeAddress(4, 5, 14, 14)); ws.AddMergedRegion(new CellRangeAddress(4, 5, 14, 14));
ws.GetRow(rowIndex + 4).GetCell(14).SetCellValue("无损检查报告\r\nNDE Report."); ws.GetRow(rowIndex + 4).GetCell(14).SetCellValue("无损检查报告\r\nNDE Report.");
ws.GetRow(rowIndex + 4).GetCell(0).CellStyle = ws.GetRow(rowIndex + 4).GetCell(1).CellStyle
= ws.GetRow(rowIndex + 4).GetCell(3).CellStyle = ws.GetRow(rowIndex + 4).GetCell(4).CellStyle
= ws.GetRow(rowIndex + 4).GetCell(5).CellStyle = ws.GetRow(rowIndex + 4).GetCell(6).CellStyle
= ws.GetRow(rowIndex + 4).GetCell(7).CellStyle = ws.GetRow(rowIndex + 4).GetCell(8).CellStyle
= ws.GetRow(rowIndex + 4).GetCell(10).CellStyle = ws.GetRow(rowIndex + 4).GetCell(12).CellStyle
= ws.GetRow(rowIndex + 4).GetCell(13).CellStyle = ws.GetRow(rowIndex + 4).GetCell(14).CellStyle = styleThree;
//这里创建行数据 //这里创建行数据
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 6, rowIndex + 23, style, 0, 14, true); ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 6, rowIndex + 23, style, 0, 14, true);
for (int i = 6; i < 24; i++) for (int i = 6; i < 24; i++)
@ -3107,7 +3122,6 @@ namespace FineUIPro.Web.WeldingProcess.TestPackageManage
ws.SetMargin(MarginType.HeaderMargin, 0); ws.SetMargin(MarginType.HeaderMargin, 0);
ws.SetMargin(MarginType.FooterMargin, 0); ws.SetMargin(MarginType.FooterMargin, 0);
} }
//22-射线检测比例确认表SHT 3503-J412-2007 //22-射线检测比例确认表SHT 3503-J412-2007
private void template22_old(XSSFWorkbook hssfworkbook, XSSFSheet ws) private void template22_old(XSSFWorkbook hssfworkbook, XSSFSheet ws)
{ {

View File

@ -732,8 +732,8 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
#endregion #endregion
#region #region
string JLAudit = tb.Rows[0]["JLAudit"].ToString(); string JLAudit = ""; //tb.Rows[0]["JLAudit"].ToString();
string GLGSAudit = tb.Rows[0]["GLGSAudit"].ToString(); string GLGSAudit = ""; //tb.Rows[0]["GLGSAudit"].ToString();
ws = WsExcelCreateRow(ws, hssfworkbook, rowIndex + 1, rowIndex + 9, style, 0, 12, 3); ws = WsExcelCreateRow(ws, hssfworkbook, rowIndex + 1, rowIndex + 9, style, 0, 12, 3);
//合并单元格 //合并单元格
for (int hb = rowIndex + 1; hb <= rowIndex + 10; hb++) for (int hb = rowIndex + 1; hb <= rowIndex + 10; hb++)

View File

@ -982,24 +982,25 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
#region #region
ws.SetColumnWidth(0, 18 * 256); ws.SetColumnWidth(0, 18 * 256);
ws.SetColumnWidth(1, 13 * 256); ws.SetColumnWidth(1, 9 * 256);
ws.SetColumnWidth(2, 10 * 256); ws.SetColumnWidth(2, 6 * 256);
ws.SetColumnWidth(3, 10 * 256); ws.SetColumnWidth(3, 12 * 256);
ws.SetColumnWidth(4, 18 * 256); ws.SetColumnWidth(4, 18 * 256);
ws.SetColumnWidth(5, 13 * 256); ws.SetColumnWidth(5, 19 * 256);
ws.SetColumnWidth(6, 16 * 256); ws.SetColumnWidth(6, 13 * 256);
ws.SetColumnWidth(7, 13 * 256); ws.SetColumnWidth(7, 13 * 256);
ws.SetColumnWidth(8, 13 * 256); ws.SetColumnWidth(8, 14 * 256);
ws.SetColumnWidth(9, 9 * 256); ws.SetColumnWidth(9, 13 * 256);
ws.SetColumnWidth(10, 13 * 256); ws.SetColumnWidth(10, 13 * 256);
ws.SetColumnWidth(11, 13 * 256); ws.SetColumnWidth(11, 10 * 256);
ws.SetColumnWidth(12, 17 * 256); ws.SetColumnWidth(12, 16 * 256);
ws.SetColumnWidth(13, 13 * 256); ws.SetColumnWidth(13, 14 * 256);
ws.SetColumnWidth(14, 12 * 256); ws.SetColumnWidth(14, 19 * 256);
#endregion #endregion
var style = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false); var style = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
var headerStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 9, true, false);
var tbNum = tb.Rows.Count; var tbNum = tb.Rows.Count;
var pageNum = var pageNum =
@ -1082,6 +1083,14 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
ws.AddMergedRegion(region); ws.AddMergedRegion(region);
ws.GetRow(rowIndex + 4).GetCell(14).SetCellValue("无损检查报告\r\nNDE Report."); ws.GetRow(rowIndex + 4).GetCell(14).SetCellValue("无损检查报告\r\nNDE Report.");
ws.GetRow(rowIndex + 4).GetCell(0).CellStyle = ws.GetRow(rowIndex + 4).GetCell(1).CellStyle
= ws.GetRow(rowIndex + 4).GetCell(3).CellStyle = ws.GetRow(rowIndex + 4).GetCell(4).CellStyle
= ws.GetRow(rowIndex + 4).GetCell(5).CellStyle = ws.GetRow(rowIndex + 4).GetCell(6).CellStyle
= ws.GetRow(rowIndex + 4).GetCell(7).CellStyle = ws.GetRow(rowIndex + 4).GetCell(8).CellStyle
= ws.GetRow(rowIndex + 4).GetCell(10).CellStyle = ws.GetRow(rowIndex + 4).GetCell(12).CellStyle
= ws.GetRow(rowIndex + 4).GetCell(13).CellStyle = ws.GetRow(rowIndex + 4).GetCell(14).CellStyle
= headerStyle;
#endregion #endregion
#region #region

View File

@ -10,6 +10,10 @@ using System.Data.SqlClient;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using NPOI.HSSF.UserModel;
using NPOI.SS.Util;
using NPOI.SS.Formula.Functions;
using NPOI.OpenXmlFormats.Wordprocessing;
namespace FineUIPro.Web.WeldingProcess.WeldingReport namespace FineUIPro.Web.WeldingProcess.WeldingReport
{ {
@ -226,179 +230,176 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read); FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
XSSFWorkbook hssfworkbook = new XSSFWorkbook(file); XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
#region WeldDailyExport hssfworkbook.RemoveAt(0);
XSSFSheet reportModel = (XSSFSheet)hssfworkbook.GetSheet("Sheet1"); XSSFSheet ws = (XSSFSheet)hssfworkbook.CreateSheet("Sheet1");
XSSFFont cs_content_Font1 = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 int rowIndex = 0;
cs_content_Font1.FontName = "sans-serif";//字体 var style = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.None, BorderStyle.None, BorderStyle.None, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 20, true, true, "微软雅黑");
cs_content_Font1.FontHeightInPoints = 9; //字体大小
ICellStyle style = hssfworkbook.CreateCellStyle();
style.SetFont(cs_content_Font1);
XSSFFont cs_content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 #region
cs_content_Font.FontName = "sans-serif";//字体 DataTable dt = GetDataTable();
cs_content_Font.FontHeightInPoints = 10; //字体大小 int totalCount = dt.Rows.Count;
cs_content_Font.Color= HSSFColor.Red.Index; int pageSize = 62;
var pageNum =
totalCount < pageSize ? 1
: Math.Ceiling((float)(totalCount - pageSize) / pageSize) + 1;
var style3 = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 9, false, false, "sans-serif");
IDataFormat dataformat = hssfworkbook.CreateDataFormat();
ICellStyle styleDate = hssfworkbook.CreateCellStyle();
styleDate.SetFont(cs_content_Font1);
styleDate.DataFormat = dataformat.GetFormat("yyyy-mm-dd");
DataTable tb = GetDataTable(); for (int i = 1; i <= pageNum; i++)
if (tb.Rows.Count > 0)
{ {
var rowIndex = 4; #region
foreach (DataRow itemOver in tb.Rows) ws = ExcelCreateRow(ws, hssfworkbook, rowIndex, rowIndex, style, 0, 19, true);
ws.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(rowIndex, rowIndex, 0, 19));
//设置表头文字
ws.GetRow(rowIndex).GetCell(0).SetCellValue("焊接日报表\nWelding Daily Report");
var style2 = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 9, true, true, "Arial");
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 1, rowIndex + 2, style2, 0, 19, true);
//设置表格表头
ws.GetRow(rowIndex + 1).GetCell(0).SetCellValue("序号");
ws.GetRow(rowIndex + 1).GetCell(1).SetCellValue("管线号-页码");
ws.GetRow(rowIndex + 1).GetCell(2).SetCellValue("图纸版本");
ws.GetRow(rowIndex + 1).GetCell(3).SetCellValue("焊口号");
ws.GetRow(rowIndex + 1).GetCell(4).SetCellValue("焊接形式");
ws.GetRow(rowIndex + 1).GetCell(5).SetCellValue("焊接位置");
ws.GetRow(rowIndex + 1).GetCell(6).SetCellValue("寸径");
ws.GetRow(rowIndex + 1).GetCell(7).SetCellValue("规格");
ws.GetRow(rowIndex + 1).GetCell(8).SetCellValue("焊工号");
ws.GetRow(rowIndex + 1).GetCell(9).SetCellValue("组对部件1");
ws.GetRow(rowIndex + 1).GetCell(10).SetCellValue("组件1材质");
ws.GetRow(rowIndex + 1).GetCell(11).SetCellValue("组件1炉批号");
ws.GetRow(rowIndex + 1).GetCell(12).SetCellValue("组对部件2");
ws.GetRow(rowIndex + 1).GetCell(13).SetCellValue("组件2材质");
ws.GetRow(rowIndex + 1).GetCell(14).SetCellValue("组件2炉批号");
ws.GetRow(rowIndex + 1).GetCell(15).SetCellValue("焊接方法");
ws.GetRow(rowIndex + 1).GetCell(16).SetCellValue("组对");
ws.GetRow(rowIndex + 1).GetCell(17).SetCellValue("外观");
ws.GetRow(rowIndex + 1).GetCell(18).SetCellValue("焊接日期");
ws.GetRow(rowIndex + 1).GetCell(19).SetCellValue("备注");
ws.GetRow(rowIndex + 2).GetCell(0).SetCellValue("S/N");
ws.GetRow(rowIndex + 2).GetCell(1).SetCellValue("LineNo.-PageNo.");
ws.GetRow(rowIndex + 2).GetCell(2).SetCellValue("Drawing\nRev");
ws.GetRow(rowIndex + 2).GetCell(3).SetCellValue("Joint\nNo.");
ws.GetRow(rowIndex + 2).GetCell(4).SetCellValue("JointType");
ws.GetRow(rowIndex + 2).GetCell(5).SetCellValue("Welding\nLocation");
ws.GetRow(rowIndex + 2).GetCell(6).SetCellValue("Inch");
ws.GetRow(rowIndex + 2).GetCell(7).SetCellValue("Size");
ws.GetRow(rowIndex + 2).GetCell(8).SetCellValue("Welder\nNo.");
ws.GetRow(rowIndex + 2).GetCell(9).SetCellValue("Part(1)");
ws.GetRow(rowIndex + 2).GetCell(10).SetCellValue("Material(1)");
ws.GetRow(rowIndex + 2).GetCell(11).SetCellValue("Heat\nNo.(1)");
ws.GetRow(rowIndex + 2).GetCell(12).SetCellValue("Part(2)");
ws.GetRow(rowIndex + 2).GetCell(13).SetCellValue("Material(2)");
ws.GetRow(rowIndex + 2).GetCell(14).SetCellValue("Heat\nNo.(2)");
ws.GetRow(rowIndex + 2).GetCell(15).SetCellValue("Weld\nProcess");
ws.GetRow(rowIndex + 2).GetCell(16).SetCellValue("Fit\nUp");
ws.GetRow(rowIndex + 2).GetCell(17).SetCellValue("VT");
ws.GetRow(rowIndex + 2).GetCell(18).SetCellValue("Welding\nDate");
ws.GetRow(rowIndex + 2).GetCell(19).SetCellValue("Remark");
ws.GetRow(rowIndex).Height = 69 * 20;
ws.GetRow(rowIndex + 1).Height = 12 * 20;
ws.GetRow(rowIndex + 2).Height = 24 * 20;
ws.SetColumnWidth(rowIndex, 4 * 256);
ws.SetColumnWidth(rowIndex + 1, (int)(22.67 * 256));
ws.SetColumnWidth(rowIndex + 2, (int)(9.78 * 256));
ws.SetColumnWidth(rowIndex + 3, (int)(6.78 * 256));
ws.SetColumnWidth(rowIndex + 4, (int)(7.67 * 256));
ws.SetColumnWidth(rowIndex + 5, (int)(8.33 * 256));
ws.SetColumnWidth(rowIndex + 6, (int)(6.33 * 256));
ws.SetColumnWidth(rowIndex + 7, (int)(9.11 * 256));
ws.SetColumnWidth(rowIndex + 8, (int)(8.33 * 256));
ws.SetColumnWidth(rowIndex + 9, (int)(7.44 * 256));
ws.SetColumnWidth(rowIndex + 10, (int)(15.67 * 256));
ws.SetColumnWidth(rowIndex + 11, (int)(11.67 * 256));
ws.SetColumnWidth(rowIndex + 12, (int)(8.22 * 256));
ws.SetColumnWidth(rowIndex + 13, (int)(16.33 * 256));
ws.SetColumnWidth(rowIndex + 14, (int)(11.22 * 256));
ws.SetColumnWidth(rowIndex + 15, (int)(10.44 * 256));
ws.SetColumnWidth(rowIndex + 16, (int)(5.56 * 256));
ws.SetColumnWidth(rowIndex + 17, (int)(5.56 * 256));
ws.SetColumnWidth(rowIndex + 18, (int)(7.89 * 256));
ws.SetColumnWidth(rowIndex + 19, (int)(9.33 * 256));
#endregion
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 3, rowIndex + 64, style3, 0, 19);
var tIndex = 3 + rowIndex;
var dStart = 0;
var dEnd = 0;
if (i == 1)
{ {
if (reportModel.GetRow(rowIndex) == null) reportModel.CreateRow(rowIndex); dStart = 0;
dEnd = pageSize;
#region
//序号
if (reportModel.GetRow(rowIndex).GetCell(0) == null) reportModel.GetRow(rowIndex).CreateCell(0);
reportModel.GetRow(rowIndex).GetCell(0).SetCellValue((rowIndex - 1).ToString());
reportModel.GetRow(rowIndex).GetCell(0).CellStyle = style; //将字体绑定到样式
//管线号-页码
if (reportModel.GetRow(rowIndex).GetCell(1) == null) reportModel.GetRow(rowIndex).CreateCell(1);
reportModel.GetRow(rowIndex).GetCell(1).SetCellValue(itemOver["SingleNumber"].ToString());
reportModel.GetRow(rowIndex).GetCell(1).CellStyle = style;
//图纸版本
if (reportModel.GetRow(rowIndex).GetCell(2) == null) reportModel.GetRow(rowIndex).CreateCell(2);
reportModel.GetRow(rowIndex).GetCell(2).SetCellValue(itemOver["DrawingsNum"].ToString());
reportModel.GetRow(rowIndex).GetCell(2).CellStyle = style;
//焊口号
if (reportModel.GetRow(rowIndex).GetCell(3) == null) reportModel.GetRow(rowIndex).CreateCell(3);
reportModel.GetRow(rowIndex).GetCell(3).SetCellValue(itemOver["WeldJointCode"].ToString());
reportModel.GetRow(rowIndex).GetCell(3).CellStyle = style;
//焊接形式
if (reportModel.GetRow(rowIndex).GetCell(4) == null) reportModel.GetRow(rowIndex).CreateCell(4);
reportModel.GetRow(rowIndex).GetCell(4).SetCellValue(itemOver["WeldTypeCode"].ToString());
reportModel.GetRow(rowIndex).GetCell(4).CellStyle = style;
//if (itemOver.FCR_COST_CNY.HasValue)
//{
// reportModel.GetRow(rowIndex).GetCell(4).SetCellValue(string.Format("{0:N}", itemOver.FCR_COST_CNY));
//}
//焊接位置
if (reportModel.GetRow(rowIndex).GetCell(5) == null) reportModel.GetRow(rowIndex).CreateCell(5);
reportModel.GetRow(rowIndex).GetCell(5).SetCellValue(itemOver["WeldingLocationCode"].ToString());
reportModel.GetRow(rowIndex).GetCell(5).CellStyle = style;
//寸径
if (reportModel.GetRow(rowIndex).GetCell(6) == null) reportModel.GetRow(rowIndex).CreateCell(6);
reportModel.GetRow(rowIndex).GetCell(6).SetCellValue(itemOver["Size"].ToString());
reportModel.GetRow(rowIndex).GetCell(6).CellStyle = style;
//规格
if (reportModel.GetRow(rowIndex).GetCell(7) == null) reportModel.GetRow(rowIndex).CreateCell(7);
reportModel.GetRow(rowIndex).GetCell(7).SetCellValue(itemOver["Specification"].ToString());
reportModel.GetRow(rowIndex).GetCell(7).CellStyle = style;
//焊工号
if (reportModel.GetRow(rowIndex).GetCell(8) == null) reportModel.GetRow(rowIndex).CreateCell(8);
reportModel.GetRow(rowIndex).GetCell(8).SetCellValue(itemOver["WelderCode"].ToString());
reportModel.GetRow(rowIndex).GetCell(8).CellStyle = style;
//组对部件
if (reportModel.GetRow(rowIndex).GetCell(9) == null) reportModel.GetRow(rowIndex).CreateCell(9);
reportModel.GetRow(rowIndex).GetCell(9).SetCellValue(itemOver["ComponentsName1"].ToString());
reportModel.GetRow(rowIndex).GetCell(9).CellStyle = style;
//组件1材质
if (reportModel.GetRow(rowIndex).GetCell(10) == null) reportModel.GetRow(rowIndex).CreateCell(10);
reportModel.GetRow(rowIndex).GetCell(10).SetCellValue(itemOver["MaterialCode1"].ToString());
reportModel.GetRow(rowIndex).GetCell(10).CellStyle = style;
//组件1炉批号
if (reportModel.GetRow(rowIndex).GetCell(11) == null) reportModel.GetRow(rowIndex).CreateCell(11);
reportModel.GetRow(rowIndex).GetCell(11).SetCellValue(itemOver["HeartNo1"].ToString());
reportModel.GetRow(rowIndex).GetCell(11).CellStyle = style;
//组对部件2
if (reportModel.GetRow(rowIndex).GetCell(12) == null) reportModel.GetRow(rowIndex).CreateCell(12);
reportModel.GetRow(rowIndex).GetCell(12).SetCellValue(itemOver["ComponentsName2"].ToString());
reportModel.GetRow(rowIndex).GetCell(12).CellStyle = style;
//组件2材质
if (reportModel.GetRow(rowIndex).GetCell(13) == null) reportModel.GetRow(rowIndex).CreateCell(13);
reportModel.GetRow(rowIndex).GetCell(13).SetCellValue(itemOver["MaterialCode2"].ToString());
reportModel.GetRow(rowIndex).GetCell(13).CellStyle = style;
//组件2炉批号
if (reportModel.GetRow(rowIndex).GetCell(14) == null) reportModel.GetRow(rowIndex).CreateCell(14);
reportModel.GetRow(rowIndex).GetCell(14).SetCellValue(itemOver["HeartNo2"].ToString());
reportModel.GetRow(rowIndex).GetCell(14).CellStyle = style;
//焊接方法
if (reportModel.GetRow(rowIndex).GetCell(15) == null) reportModel.GetRow(rowIndex).CreateCell(15);
reportModel.GetRow(rowIndex).GetCell(15).SetCellValue(itemOver["WeldingMethodName"].ToString());
reportModel.GetRow(rowIndex).GetCell(15).CellStyle = style;
//焊材牌号
if (reportModel.GetRow(rowIndex).GetCell(16) == null) reportModel.GetRow(rowIndex).CreateCell(16);
//reportModel.GetRow(rowIndex).GetCell(16).SetCellValue(ConvertWeldMaterial(itemOver["WeldMaterial"]));
reportModel.GetRow(rowIndex).GetCell(16).SetCellValue("ACC");
reportModel.GetRow(rowIndex).GetCell(16).CellStyle = style;
//探伤比例
if (reportModel.GetRow(rowIndex).GetCell(17) == null) reportModel.GetRow(rowIndex).CreateCell(17);
reportModel.GetRow(rowIndex).GetCell(17).SetCellValue("ACC");
//reportModel.GetRow(rowIndex).GetCell(17).SetCellValue(itemOver["DetectionRateCode"].ToString());
reportModel.GetRow(rowIndex).GetCell(17).CellStyle = style;
//焊接日期
if (reportModel.GetRow(rowIndex).GetCell(18) == null) reportModel.GetRow(rowIndex).CreateCell(18);
reportModel.GetRow(rowIndex).GetCell(18).SetCellValue(itemOver["WeldingDate"].ToString());
reportModel.GetRow(rowIndex).GetCell(18).CellStyle = styleDate;
//备注
if (reportModel.GetRow(rowIndex).GetCell(19) == null) reportModel.GetRow(rowIndex).CreateCell(19);
reportModel.GetRow(rowIndex).GetCell(19).SetCellValue(itemOver["Remark"].ToString());
reportModel.GetRow(rowIndex).GetCell(19).CellStyle = style;
#endregion
rowIndex++;
}
var distinctPipelineCode = tb.AsEnumerable().GroupBy(row => row.Field<string>("PipelineCode")).Select(group => group.First());
var distinctWelder = tb.AsEnumerable().GroupBy(row => row.Field<string>("WelderCode")).Select(group => group.First());
decimal sumSize = decimal.Parse(tb.Compute("sum(Size)", "").ToString());
string weldingDate = string.Empty;
if (txtStarTime.Text == txtEndTime.Text)
{
weldingDate = txtStarTime.Text;
} }
else else
{ {
weldingDate = txtStarTime.Text + "-" + txtEndTime.Text; dStart = i == 2 ? pageSize : ((i - 2) * pageSize) + pageSize;
dEnd = ((i - 1) * pageSize) + pageSize;
} }
// 合计 var pageTb = GetPageToTable(dt, dStart, dEnd);
if (reportModel.GetRow(rowIndex) == null) reportModel.CreateRow(rowIndex); for (int j = 0; j < pageTb.Rows.Count; j++)
if (reportModel.GetRow(rowIndex).GetCell(0) == null) reportModel.GetRow(rowIndex).CreateCell(0); {
reportModel.GetRow(rowIndex).GetCell(0).SetCellValue("合计Total"); int dataIndex = tIndex + j;
reportModel.GetRow(rowIndex).GetCell(0).CellStyle.SetFont(cs_content_Font);//将字体绑定到样式 ws.GetRow(dataIndex).GetCell(0).SetCellValue(j + 1);
ws.GetRow(dataIndex).GetCell(1).SetCellValue(pageTb.Rows[j]["SingleNumber"].ToString());
//管线号-页码 ws.GetRow(dataIndex).GetCell(2).SetCellValue(pageTb.Rows[j]["DrawingsNum"].ToString());
if (reportModel.GetRow(rowIndex).GetCell(1) == null) reportModel.GetRow(rowIndex).CreateCell(1); ws.GetRow(dataIndex).GetCell(3).SetCellValue(pageTb.Rows[j]["WeldJointCode"].ToString());
reportModel.GetRow(rowIndex).GetCell(1).SetCellValue(distinctPipelineCode.Count().ToString()); ws.GetRow(dataIndex).GetCell(4).SetCellValue(pageTb.Rows[j]["WeldTypeCode"].ToString());
reportModel.GetRow(rowIndex).GetCell(1).CellStyle.SetFont(cs_content_Font); ws.GetRow(dataIndex).GetCell(5).SetCellValue(pageTb.Rows[j]["WeldingLocationCode"].ToString());
ws.GetRow(dataIndex).GetCell(6).SetCellValue(pageTb.Rows[j]["Size"].ToString());
//焊口号 ws.GetRow(dataIndex).GetCell(7).SetCellValue(pageTb.Rows[j]["Specification"].ToString());
if (reportModel.GetRow(rowIndex).GetCell(3) == null) reportModel.GetRow(rowIndex).CreateCell(3); ws.GetRow(dataIndex).GetCell(8).SetCellValue(pageTb.Rows[j]["WelderCode"].ToString());
reportModel.GetRow(rowIndex).GetCell(3).SetCellValue(tb.Rows.Count); ws.GetRow(dataIndex).GetCell(9).SetCellValue(pageTb.Rows[j]["ComponentsName1"].ToString());
reportModel.GetRow(rowIndex).GetCell(3).CellStyle.SetFont(cs_content_Font); ws.GetRow(dataIndex).GetCell(10).SetCellValue(pageTb.Rows[j]["MaterialCode1"].ToString());
ws.GetRow(dataIndex).GetCell(11).SetCellValue(pageTb.Rows[j]["HeartNo1"].ToString());
if (reportModel.GetRow(rowIndex).GetCell(6) == null) reportModel.GetRow(rowIndex).CreateCell(6); ws.GetRow(dataIndex).GetCell(12).SetCellValue(pageTb.Rows[j]["ComponentsName2"].ToString());
reportModel.GetRow(rowIndex).GetCell(6).SetCellValue(sumSize.ToString()); ws.GetRow(dataIndex).GetCell(13).SetCellValue(pageTb.Rows[j]["MaterialCode2"].ToString());
reportModel.GetRow(rowIndex).GetCell(6).CellStyle.SetFont(cs_content_Font); ws.GetRow(dataIndex).GetCell(14).SetCellValue(pageTb.Rows[j]["HeartNo2"].ToString());
ws.GetRow(dataIndex).GetCell(15).SetCellValue(pageTb.Rows[j]["WeldingMethodName"].ToString());
//焊工号 ws.GetRow(dataIndex).GetCell(16).SetCellValue("ACC");
if (reportModel.GetRow(rowIndex).GetCell(8) == null) reportModel.GetRow(rowIndex).CreateCell(8); ws.GetRow(dataIndex).GetCell(17).SetCellValue("ACC");
reportModel.GetRow(rowIndex).GetCell(8).SetCellValue(distinctWelder.Count().ToString()); ws.GetRow(dataIndex).GetCell(18).SetCellValue(pageTb.Rows[j]["WeldingDate"].ToString());
reportModel.GetRow(rowIndex).GetCell(8).CellStyle.SetFont(cs_content_Font); ws.GetRow(dataIndex).GetCell(19).SetCellValue(pageTb.Rows[j]["Remark"].ToString());
ws.GetRow(dataIndex).Height = 10 * 20;
//焊接日期 }
if (reportModel.GetRow(rowIndex).GetCell(18) == null) reportModel.GetRow(rowIndex).CreateCell(18); rowIndex += tIndex + 62;
reportModel.GetRow(rowIndex).GetCell(18).SetCellValue(weldingDate);
reportModel.GetRow(rowIndex).GetCell(18).CellStyle.SetFont(cs_content_Font);
} }
#endregion #endregion
reportModel.ForceFormulaRecalculation = true;
#region
IFooter footer = ws.Footer;
string str= "CC7: 监理: Worley:";
str += "\n\n第 &P 页,共 &N 页";
footer.Center = str;
#endregion
ws.PrintSetup.FitWidth = 1;
ws.PrintSetup.FitHeight = 0;
ws.PrintSetup.PaperSize = (int)PaperSize.A4_Small;
ws.FitToPage = false;
ws.SetMargin(MarginType.LeftMargin, (double)1.2 / 3);
ws.SetMargin(MarginType.RightMargin, (double)1.2 / 3);
ws.SetMargin(MarginType.TopMargin, (double)1.8 / 3);
ws.SetMargin(MarginType.BottomMargin, (double)2.9 / 3);
ws.PrintSetup.Landscape = true;
ws.PrintSetup.Scale = 70;
ws.ForceFormulaRecalculation = true;
using (FileStream filess = System.IO.File.OpenWrite(ReportFileName)) using (FileStream filess = System.IO.File.OpenWrite(ReportFileName))
{ {
hssfworkbook.Write(filess); hssfworkbook.Write(filess);
} }
hssfworkbook.Close();
FileInfo filet = new FileInfo(ReportFileName); FileInfo filet = new FileInfo(ReportFileName);
Response.Clear(); Response.Clear();
Response.Charset = "GB2312"; Response.Charset = "GB2312";
@ -413,14 +414,6 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
Response.WriteFile(filet.FullName); Response.WriteFile(filet.FullName);
// 停止页面的执行 // 停止页面的执行
Response.End(); Response.End();
//Response.ClearContent();
//string filename = Funs.GetNewFileName();
//Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("焊接日报表" + filename, System.Text.Encoding.UTF8) + ".xls");
//Response.ContentType = "application/excel";
//Response.ContentEncoding = System.Text.Encoding.UTF8;
//Response.Write(GetGridTableHtml(Grid1));
//Response.End();
} }
/// <summary> /// <summary>
@ -597,5 +590,69 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
} }
#endregion #endregion
public static DataTable GetPageToTable(DataTable dt, int StartNum, int EndNum)
{
//0页代表每页数据直接返回
if (EndNum == 0) return dt;
//数据源为空返回空DataTable
if (dt == null) return new DataTable();
DataTable newdt = dt.Copy();
newdt.Clear();//copy dt的框架
if (StartNum >= dt.Rows.Count)
return newdt;//源数据记录数小于等于要显示的记录直接返回dt
if (EndNum > dt.Rows.Count)
EndNum = dt.Rows.Count;
for (int i = StartNum; i <= EndNum - 1; i++)
{
DataRow newdr = newdt.NewRow();
DataRow dr = dt.Rows[i];
foreach (DataColumn column in dt.Columns)
{
newdr[column.ColumnName] = dr[column.ColumnName];
}
newdt.Rows.Add(newdr);
}
return newdt;
}
private XSSFSheet ExcelCreateRow(XSSFSheet ws, XSSFWorkbook hssfworkbook, int sRows, int eRows, ICellStyle style, int cStart, int cEnd, bool istitle = false)
{
for (int i = sRows; i <= eRows; i++)
{
ws.CreateRow(i);
if (istitle)
{
ws.GetRow(i).HeightInPoints =
i == sRows ? 49.75f :
i == (sRows + 1) ? 13.75f :
38f;
}
else
{
ws.GetRow(i).HeightInPoints = 38f;
}
for (int j = cStart; j <= cEnd; j++)
{
ws.GetRow(i).CreateCell(j);
ws.GetRow(i).GetCell(j).CellStyle = style;
}
}
return ws;
}
private ICellStyle SetStyle(XSSFWorkbook ws, BorderStyle top, BorderStyle bottom, BorderStyle left, BorderStyle right)
{
ICellStyle style = ws.CreateCellStyle();
style.BorderLeft = left;
style.BorderRight = right;
style.BorderTop = top;
style.BorderBottom = bottom;
return style;
}
} }
} }

Binary file not shown.