This commit is contained in:
commit
77e4a4467d
Binary file not shown.
|
@ -315,70 +315,12 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
|
|||
ws.SetColumnWidth(18, (int)(7.89 * 256));
|
||||
ws.SetColumnWidth(19, (int)(9.33 * 256));
|
||||
#endregion
|
||||
|
||||
//#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++)
|
||||
//{
|
||||
|
||||
|
||||
// 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);
|
||||
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 3, dt.Rows.Count+2, style3, 0, 19);
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
int startIndex = (i + 3);
|
||||
|
@ -410,6 +352,34 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
|
|||
}
|
||||
}
|
||||
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
string weldingDate = string.Empty;
|
||||
if (txtStarTime.Text == txtEndTime.Text)
|
||||
{
|
||||
weldingDate = txtStarTime.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
weldingDate = txtStarTime.Text + "-" + txtEndTime.Text;
|
||||
}
|
||||
var style4 = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 10, true,true, "Arial");
|
||||
|
||||
ws = ExcelCreateRow(ws, hssfworkbook, dt.Rows.Count + 3, dt.Rows.Count + 3, style4, 0, 19);
|
||||
var distinctPipelineCode = dt.AsEnumerable().GroupBy(row => row.Field<string>("PipelineCode")).Select(group => group.First());
|
||||
var distinctWelder = dt.AsEnumerable().GroupBy(row => row.Field<string>("WelderCode")).Select(group => group.First());
|
||||
decimal sumSize = decimal.Parse(dt.Compute("sum(Size)", "").ToString());
|
||||
|
||||
ws.GetRow(dt.Rows.Count + 3).GetCell(0).SetCellValue("合计");
|
||||
ws.GetRow(dt.Rows.Count + 3).GetCell(1).SetCellValue($"{distinctPipelineCode.Count().ToString()}");
|
||||
ws.GetRow(dt.Rows.Count + 3).GetCell(3).SetCellValue($"{dt.Rows.Count}");
|
||||
ws.GetRow(dt.Rows.Count + 3).GetCell(6).SetCellValue($"{sumSize}");
|
||||
ws.GetRow(dt.Rows.Count + 3).GetCell(8).SetCellValue($"{distinctWelder.Count().ToString()}");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#region 页脚部分
|
||||
IFooter footer = ws.Footer;
|
||||
string str = "CC7: 监理: Worley:";
|
||||
|
@ -420,9 +390,6 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
|
|||
#endregion
|
||||
|
||||
|
||||
#region
|
||||
|
||||
#endregion
|
||||
|
||||
ws.FitToPage = false;
|
||||
ws.SetMargin(MarginType.LeftMargin, (double)1.2 / 3);
|
||||
|
@ -459,53 +426,7 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
|
|||
Response.End();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出方法
|
||||
/// </summary>
|
||||
/// <param name="grid"></param>
|
||||
/// <returns></returns>
|
||||
//private string GetGridTableHtml(Grid grid)
|
||||
//{
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// grid.PageSize = 500000;
|
||||
// BindGrid();
|
||||
|
||||
// sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
||||
// sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
||||
// sb.Append("<tr>");
|
||||
// foreach (GridColumn column in grid.Columns)
|
||||
// {
|
||||
// sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
||||
// }
|
||||
// sb.Append("</tr>");
|
||||
// foreach (GridRow row in grid.Rows)
|
||||
// {
|
||||
// sb.Append("<tr>");
|
||||
// foreach (GridColumn column in grid.Columns)
|
||||
// {
|
||||
// string html = row.Values[column.ColumnIndex].ToString();
|
||||
// if (column.ColumnID == "tfNumber")
|
||||
// {
|
||||
// html = (row.FindControl("labNumber") as AspNet.Label).Text;
|
||||
// }
|
||||
// if (column.ColumnID == "tfIsHotProess")
|
||||
// {
|
||||
// html = (row.FindControl("lblIsHotProess") as AspNet.Label).Text;
|
||||
// }
|
||||
// //if (column.ColumnID == "tfif_dk")
|
||||
// //{
|
||||
// // html = (row.FindControl("lblif_dk") as AspNet.Label).Text;
|
||||
// //}
|
||||
// sb.AppendFormat("<td>{0}</td>", html);
|
||||
// }
|
||||
|
||||
// sb.Append("</tr>");
|
||||
// }
|
||||
// sb.Append("</table>");
|
||||
|
||||
// return sb.ToString();
|
||||
//}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region 格式化字符串
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue