Merge branch 'master' of http://47.104.102.122:3000/shecs/Basf_TCC7
This commit is contained in:
commit
1f3e267e2a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -14,6 +14,9 @@ using NPOI.HSSF.UserModel;
|
|||
using NPOI.SS.Util;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using NPOI.OpenXmlFormats.Wordprocessing;
|
||||
using System.Web.UI.WebControls;
|
||||
using BorderStyle = NPOI.SS.UserModel.BorderStyle;
|
||||
using System.Data.Linq;
|
||||
|
||||
namespace FineUIPro.Web.WeldingProcess.WeldingReport
|
||||
{
|
||||
|
@ -236,20 +239,6 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
|
|||
int rowIndex = 0;
|
||||
var style = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.None, BorderStyle.None, BorderStyle.None, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 20, true, true, "微软雅黑");
|
||||
|
||||
|
||||
|
||||
#region 数据部分
|
||||
DataTable dt = GetDataTable();
|
||||
int totalCount = dt.Rows.Count;
|
||||
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");
|
||||
|
||||
|
||||
for (int i = 1; i <= pageNum; i++)
|
||||
{
|
||||
#region 头部
|
||||
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex, rowIndex, style, 0, 19, true);
|
||||
ws.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(rowIndex, rowIndex, 0, 19));
|
||||
|
@ -305,73 +294,121 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
|
|||
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));
|
||||
ws.SetColumnWidth(0, 4 * 256);
|
||||
ws.SetColumnWidth(1, (int)(22.67 * 256));
|
||||
ws.SetColumnWidth(2, (int)(9.78 * 256));
|
||||
ws.SetColumnWidth(3, (int)(6.78 * 256));
|
||||
ws.SetColumnWidth(4, (int)(7.67 * 256));
|
||||
ws.SetColumnWidth(5, (int)(8.33 * 256));
|
||||
ws.SetColumnWidth(6, (int)(6.33 * 256));
|
||||
ws.SetColumnWidth(7, (int)(9.11 * 256));
|
||||
ws.SetColumnWidth(8, (int)(8.33 * 256));
|
||||
ws.SetColumnWidth(9, (int)(7.44 * 256));
|
||||
ws.SetColumnWidth(10, (int)(15.67 * 256));
|
||||
ws.SetColumnWidth(11, (int)(11.67 * 256));
|
||||
ws.SetColumnWidth(12, (int)(8.22 * 256));
|
||||
ws.SetColumnWidth(13, (int)(16.33 * 256));
|
||||
ws.SetColumnWidth(14, (int)(11.22 * 256));
|
||||
ws.SetColumnWidth(15, (int)(10.44 * 256));
|
||||
ws.SetColumnWidth(16, (int)(5.56 * 256));
|
||||
ws.SetColumnWidth(17, (int)(5.56 * 256));
|
||||
ws.SetColumnWidth(18, (int)(7.89 * 256));
|
||||
ws.SetColumnWidth(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)
|
||||
{
|
||||
dStart = 0;
|
||||
dEnd = pageSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
dStart = i == 2 ? pageSize : ((i - 2) * pageSize) + pageSize;
|
||||
dEnd = ((i - 1) * pageSize) + pageSize;
|
||||
}
|
||||
//#region 数据部分
|
||||
//DataTable dt = GetDataTable();
|
||||
//int totalCount = dt.Rows.Count;
|
||||
//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");
|
||||
|
||||
var pageTb = GetPageToTable(dt, dStart, dEnd);
|
||||
for (int j = 0; j < pageTb.Rows.Count; j++)
|
||||
{
|
||||
int dataIndex = tIndex + j;
|
||||
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());
|
||||
ws.GetRow(dataIndex).GetCell(3).SetCellValue(pageTb.Rows[j]["WeldJointCode"].ToString());
|
||||
ws.GetRow(dataIndex).GetCell(4).SetCellValue(pageTb.Rows[j]["WeldTypeCode"].ToString());
|
||||
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());
|
||||
ws.GetRow(dataIndex).GetCell(8).SetCellValue(pageTb.Rows[j]["WelderCode"].ToString());
|
||||
ws.GetRow(dataIndex).GetCell(9).SetCellValue(pageTb.Rows[j]["ComponentsName1"].ToString());
|
||||
ws.GetRow(dataIndex).GetCell(10).SetCellValue(pageTb.Rows[j]["MaterialCode1"].ToString());
|
||||
ws.GetRow(dataIndex).GetCell(11).SetCellValue(pageTb.Rows[j]["HeartNo1"].ToString());
|
||||
ws.GetRow(dataIndex).GetCell(12).SetCellValue(pageTb.Rows[j]["ComponentsName2"].ToString());
|
||||
ws.GetRow(dataIndex).GetCell(13).SetCellValue(pageTb.Rows[j]["MaterialCode2"].ToString());
|
||||
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");
|
||||
ws.GetRow(dataIndex).GetCell(17).SetCellValue("ACC");
|
||||
ws.GetRow(dataIndex).GetCell(18).SetCellValue(pageTb.Rows[j]["WeldingDate"].ToString());
|
||||
ws.GetRow(dataIndex).GetCell(19).SetCellValue(pageTb.Rows[j]["Remark"].ToString());
|
||||
ws.GetRow(dataIndex).Height = 10 * 20;
|
||||
}
|
||||
rowIndex += tIndex + 62;
|
||||
}
|
||||
//for (int i = 1; i <= pageNum; i++)
|
||||
//{
|
||||
|
||||
#endregion
|
||||
|
||||
// ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 3, rowIndex + 66, style3, 0, 19);
|
||||
// var tIndex = 3 + rowIndex;
|
||||
// var dStart = 0;
|
||||
// var dEnd = 0;
|
||||
// if (i == 1)
|
||||
// {
|
||||
// dStart = 0;
|
||||
// dEnd = pageSize;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dStart = i == 2 ? pageSize : ((i - 2) * pageSize) + pageSize;
|
||||
// dEnd = ((i - 1) * pageSize) + pageSize;
|
||||
// }
|
||||
|
||||
// var pageTb = GetPageToTable(dt, dStart, dEnd);
|
||||
// for (int j = 0; j < pageTb.Rows.Count; j++)
|
||||
// {
|
||||
// int dataIndex = tIndex + j;
|
||||
// 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());
|
||||
// ws.GetRow(dataIndex).GetCell(3).SetCellValue(pageTb.Rows[j]["WeldJointCode"].ToString());
|
||||
// ws.GetRow(dataIndex).GetCell(4).SetCellValue(pageTb.Rows[j]["WeldTypeCode"].ToString());
|
||||
// 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());
|
||||
// ws.GetRow(dataIndex).GetCell(8).SetCellValue(pageTb.Rows[j]["WelderCode"].ToString());
|
||||
// ws.GetRow(dataIndex).GetCell(9).SetCellValue(pageTb.Rows[j]["ComponentsName1"].ToString());
|
||||
// ws.GetRow(dataIndex).GetCell(10).SetCellValue(pageTb.Rows[j]["MaterialCode1"].ToString());
|
||||
// ws.GetRow(dataIndex).GetCell(11).SetCellValue(pageTb.Rows[j]["HeartNo1"].ToString());
|
||||
// ws.GetRow(dataIndex).GetCell(12).SetCellValue(pageTb.Rows[j]["ComponentsName2"].ToString());
|
||||
// ws.GetRow(dataIndex).GetCell(13).SetCellValue(pageTb.Rows[j]["MaterialCode2"].ToString());
|
||||
// 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");
|
||||
// ws.GetRow(dataIndex).GetCell(17).SetCellValue("ACC");
|
||||
// ws.GetRow(dataIndex).GetCell(18).SetCellValue(pageTb.Rows[j]["WeldingDate"].ToString());
|
||||
// ws.GetRow(dataIndex).GetCell(19).SetCellValue(pageTb.Rows[j]["Remark"].ToString());
|
||||
// ws.GetRow(dataIndex).Height = 10 * 20;
|
||||
// }
|
||||
// rowIndex += tIndex + 63;
|
||||
//}
|
||||
|
||||
//#endregion
|
||||
const int pageSize = 64;
|
||||
DataTable dt = GetDataTable();
|
||||
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");
|
||||
|
||||
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 3, dt.Rows.Count+3, style3, 0, 19);
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
int startIndex = (i + 3);
|
||||
ws.GetRow(startIndex).GetCell(0).SetCellValue(i + 1);
|
||||
ws.GetRow(startIndex).GetCell(1).SetCellValue(dt.Rows[i]["SingleNumber"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(2).SetCellValue(dt.Rows[i]["DrawingsNum"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(3).SetCellValue(dt.Rows[i]["WeldJointCode"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(4).SetCellValue(dt.Rows[i]["WeldTypeCode"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(5).SetCellValue(dt.Rows[i]["WeldingLocationCode"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(6).SetCellValue(dt.Rows[i]["Size"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(7).SetCellValue(dt.Rows[i]["Specification"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(8).SetCellValue(dt.Rows[i]["WelderCode"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(9).SetCellValue(dt.Rows[i]["ComponentsName1"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(10).SetCellValue(dt.Rows[i]["MaterialCode1"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(11).SetCellValue(dt.Rows[i]["HeartNo1"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(12).SetCellValue(dt.Rows[i]["ComponentsName2"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(13).SetCellValue(dt.Rows[i]["MaterialCode2"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(14).SetCellValue(dt.Rows[i]["HeartNo2"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(15).SetCellValue(dt.Rows[i]["WeldingMethodName"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(16).SetCellValue("ACC");
|
||||
ws.GetRow(startIndex).GetCell(17).SetCellValue("ACC");
|
||||
ws.GetRow(startIndex).GetCell(18).SetCellValue(dt.Rows[i]["WeldingDate"].ToString());
|
||||
ws.GetRow(startIndex).GetCell(19).SetCellValue(dt.Rows[i]["Remark"].ToString());
|
||||
ws.GetRow(startIndex).Height = 10 * 20;
|
||||
if (startIndex == pageSize)
|
||||
{
|
||||
ws.SetRowBreak(startIndex);
|
||||
startIndex += pageSize;
|
||||
}
|
||||
}
|
||||
|
||||
#region 页脚部分
|
||||
IFooter footer = ws.Footer;
|
||||
|
@ -399,6 +436,8 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
|
|||
ws.PrintSetup.FitWidth = 1;
|
||||
ws.PrintSetup.FitHeight = 0;
|
||||
ws.PrintSetup.PaperSize = (int)PaperSize.A4_Small;
|
||||
ws.RepeatingRows = new NPOI.SS.Util.CellRangeAddress(0,2, 0, 19);
|
||||
|
||||
using (FileStream filess = System.IO.File.OpenWrite(ReportFileName))
|
||||
{
|
||||
hssfworkbook.Write(filess);
|
||||
|
|
Loading…
Reference in New Issue