2024-05-08 10:02:08 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using NPOI.HSSF.Util;
|
|
|
|
|
using NPOI.SS.UserModel;
|
|
|
|
|
using NPOI.SS.Util;
|
|
|
|
|
using NPOI.XSSF.UserModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using BLL;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
namespace FineUIPro.Web.WeldingProcess.TrustManage
|
|
|
|
|
{
|
|
|
|
|
public partial class NDTTrustPrint : 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
|
|
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
|
|
|
BLL.Project_InstallationService.InitInstallationDropDownList(this.drpInstallation, true, this.CurrUser.LoginProjectId, Resources.Lan.PleaseSelect);
|
|
|
|
|
BLL.Base_DetectionTypeService.InitDetectionTypeDropDownList(this.drpNDEType, Resources.Lan.PleaseSelect, true, string.Empty);//探伤类型
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 绑定数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void BindGrid()
|
|
|
|
|
{
|
|
|
|
|
string strSql = @"SELECT TrustBatchId,TrustBatchCode,InstallationCode, PipelineCode,UnitCode,TrustDate,DetectionTypeCode,
|
|
|
|
|
(case when CheckTrustBatchId is null then '未检测' else '已检测' end ) as TrustIsCheck
|
|
|
|
|
FROM dbo.View_Batch_BatchTrust WHERE ProjectId=@ProjectId ";
|
|
|
|
|
|
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
|
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
|
|
|
if (drpInstallation.SelectedValue != Const._Null)
|
|
|
|
|
{
|
|
|
|
|
strSql += " AND InstallationId = @InstallationId";
|
|
|
|
|
listStr.Add(new SqlParameter("@InstallationId", drpInstallation.SelectedValue));
|
|
|
|
|
}
|
|
|
|
|
if (drpNDEType.SelectedValue != Const._Null)
|
|
|
|
|
{
|
|
|
|
|
strSql += " AND DetectionTypeId = @DetectionTypeId";
|
|
|
|
|
listStr.Add(new SqlParameter("@DetectionTypeId", drpNDEType.SelectedValue));
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(this.txtTrustBatchCode.Text))
|
|
|
|
|
{
|
|
|
|
|
strSql += " AND TrustBatchCode LIKE @TrustBatchCode";
|
|
|
|
|
listStr.Add(new SqlParameter("@TrustBatchCode", "%" + this.txtTrustBatchCode.Text.Trim() + "%"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(this.txtTrustStartDate.Text))
|
|
|
|
|
{
|
|
|
|
|
strSql += " AND TrustDate >= @TrustStartDate";
|
|
|
|
|
listStr.Add(new SqlParameter("@TrustStartDate", Convert.ToDateTime(this.txtTrustStartDate.Text)));
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(this.txtTrustEndDate.Text))
|
|
|
|
|
{
|
|
|
|
|
strSql += " AND TrustDate < @TrustEndDate";
|
|
|
|
|
listStr.Add(new SqlParameter("@TrustEndDate", Convert.ToDateTime(this.txtTrustEndDate.Text).AddDays(1)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
|
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
|
this.Grid1.RecordCount = tb.Rows.Count;
|
|
|
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
|
|
|
Grid1.DataSource = table;
|
|
|
|
|
Grid1.DataBind();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 改变索引事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页下拉选择事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 排序
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.BindGrid();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 统计按钮事件
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 统计
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void BtnAnalyse_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindGrid();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 检测委托单打印
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检测委托单打印
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected void btnPrint_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_NDTTrustPrintMenuId, Const.BtnPrint))
|
|
|
|
|
{
|
|
|
|
|
percent = 0;
|
|
|
|
|
url = "";
|
|
|
|
|
|
|
|
|
|
Thread t = new Thread(new ThreadStart(() => { Print(); }));
|
|
|
|
|
t.Start();
|
|
|
|
|
PageContext.RegisterStartupScript("showProcessBar()");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Print()
|
|
|
|
|
{
|
|
|
|
|
if (Grid1.SelectedRowIndexArray.Length <= 0)
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop("最少选中一行!", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
|
|
|
|
|
//导出文件
|
|
|
|
|
string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
|
|
|
|
|
if (!Directory.Exists(filePath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(filePath);
|
|
|
|
|
}
|
|
|
|
|
string ReportFileName = filePath + "无损检测委托单" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx";
|
|
|
|
|
//string ReportFileName = filePath + "out1.xlsx";
|
|
|
|
|
|
|
|
|
|
int totalNum = Grid1.SelectedRowIDArray.Length;
|
|
|
|
|
int num = 1;
|
|
|
|
|
int rowIndex = 0;
|
|
|
|
|
XSSFWorkbook hssfworkbook = new XSSFWorkbook();
|
|
|
|
|
|
|
|
|
|
XSSFSheet ws = new XSSFSheet();
|
|
|
|
|
//for (int gi = 0; gi < Grid1.SelectedRowIDArray.Length; gi++)
|
|
|
|
|
foreach(string trustId in Grid1.SelectedRowIDArray)
|
|
|
|
|
{
|
|
|
|
|
var trust = BLL.Batch_BatchTrustService.GetBatchTrustViewById(trustId);
|
|
|
|
|
string trustBatchId = trust.TrustBatchId.ToString();
|
|
|
|
|
string detectionTypeCode = trust.DetectionTypeCode.ToString();
|
|
|
|
|
//头部
|
|
|
|
|
var listStr = new List<SqlParameter>();
|
|
|
|
|
listStr.Add(new SqlParameter("@TrustBatchId", trustBatchId));
|
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
|
|
|
var tbTitle = SQLHelper.GetDataTableRunProc("sp_TrustReport", parameter);
|
|
|
|
|
//列表
|
|
|
|
|
var listTitleStr = new List<SqlParameter>();
|
|
|
|
|
listTitleStr.Add(new SqlParameter("@TrustBatchId", trustBatchId));
|
|
|
|
|
SqlParameter[] titleparameter = listTitleStr.ToArray();
|
|
|
|
|
var tb = SQLHelper.GetDataTableRunProc("TrustItemReport", titleparameter);
|
|
|
|
|
DateTime? trustDate = Funs.GetNewDateTime(tbTitle.Rows[0]["TrustDate"].ToString());
|
|
|
|
|
|
|
|
|
|
var style = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
|
|
|
|
|
var styleButton = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
|
|
|
|
|
var styleTop = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
|
|
|
|
|
var styleNone = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
|
|
|
|
|
|
|
|
|
|
if (detectionTypeCode.Trim() == "PMI")
|
|
|
|
|
{
|
|
|
|
|
if (hssfworkbook.GetSheet("材料及配件检测委托单") != null)
|
|
|
|
|
{
|
|
|
|
|
ws = (XSSFSheet)hssfworkbook.GetSheet("材料及配件检测委托单");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rowIndex = 0;
|
|
|
|
|
ws = (XSSFSheet)hssfworkbook.CreateSheet("材料及配件检测委托单");
|
|
|
|
|
|
|
|
|
|
#region 列宽
|
|
|
|
|
|
|
|
|
|
ws.SetColumnWidth(0, 5 * 256);
|
|
|
|
|
ws.SetColumnWidth(1, 7 * 256);
|
|
|
|
|
ws.SetColumnWidth(2, 9 * 256);
|
|
|
|
|
ws.SetColumnWidth(3, 5 * 256);
|
|
|
|
|
ws.SetColumnWidth(4, 5 * 256);
|
|
|
|
|
ws.SetColumnWidth(5, 5 * 256);
|
|
|
|
|
ws.SetColumnWidth(6, 5 * 256);
|
|
|
|
|
ws.SetColumnWidth(7, 6 * 256);
|
|
|
|
|
ws.SetColumnWidth(8, 6 * 256);
|
|
|
|
|
ws.SetColumnWidth(9, 9 * 256);
|
|
|
|
|
ws.SetColumnWidth(10, 8 * 256);
|
|
|
|
|
ws.SetColumnWidth(11, 8 * 256);
|
|
|
|
|
ws.SetColumnWidth(12, 5 * 256);
|
|
|
|
|
ws.SetColumnWidth(13, 9 * 256);
|
|
|
|
|
ws.SetColumnWidth(14, 4 * 256);
|
|
|
|
|
ws.SetColumnWidth(15, 4 * 256);
|
|
|
|
|
ws.SetColumnWidth(16, 4 * 256);
|
|
|
|
|
ws.SetColumnWidth(17, 5 * 256);
|
|
|
|
|
ws.SetColumnWidth(18, 10 * 256);
|
|
|
|
|
ws.SetColumnWidth(19, 8 * 256);
|
|
|
|
|
ws.SetColumnWidth(20, 8 * 256);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tb.Rows.Count > 0 && tbTitle.Rows.Count > 0)
|
|
|
|
|
{
|
2024-06-24 17:41:45 +08:00
|
|
|
|
string jlAuditer = tb.Rows[0]["JLAuditID"].ToString();
|
|
|
|
|
string glgsAuditer = tb.Rows[0]["GLGSAuditID"].ToString();
|
|
|
|
|
var getJLInfo = BLL.Sys_UserService.GetSingtrueImageUrl(jlAuditer);
|
|
|
|
|
var getGLGSInfo = BLL.Sys_UserService.GetSingtrueImageUrl(glgsAuditer);
|
|
|
|
|
|
2024-05-08 10:02:08 +08:00
|
|
|
|
var tbNum = tb.Rows.Count;
|
|
|
|
|
var pageNum =
|
|
|
|
|
tbNum < 17 ? 1
|
|
|
|
|
: Math.Ceiling((float)(tbNum - 16) / 16) + 1;
|
|
|
|
|
|
|
|
|
|
//循环页
|
|
|
|
|
for (int i = 1; i <= pageNum; i++)
|
|
|
|
|
{
|
2024-06-24 17:41:45 +08:00
|
|
|
|
|
2024-05-08 10:02:08 +08:00
|
|
|
|
#region 头部
|
|
|
|
|
|
|
|
|
|
ws = ClExcelCreateRow(ws, hssfworkbook, rowIndex, rowIndex + 5, style, 0, 20, true);
|
|
|
|
|
|
|
|
|
|
//行0
|
|
|
|
|
CellRangeAddress region = new CellRangeAddress(rowIndex, rowIndex + 3, 0, 4);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(0).SetCellValue(tbTitle.Rows[0]["PipelineCode"].ToString());
|
|
|
|
|
region = new CellRangeAddress(rowIndex, rowIndex + 3, 5, 15);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(5).SetCellValue("材料及配件检测委托单");
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(5).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 16, true, true);
|
|
|
|
|
region = new CellRangeAddress(rowIndex, rowIndex, 16, 20);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(16).SetCellValue(tbTitle.Rows[0]["ProjectName"].ToString());
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(16).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Justify, 10, true, false);
|
|
|
|
|
|
|
|
|
|
//行1
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 16, 20);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(16).SetCellValue("");
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(16).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Justify, 9, true, false);
|
|
|
|
|
|
|
|
|
|
//行2
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 2, rowIndex + 2, 16, 20);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 2).GetCell(16).SetCellValue(tbTitle.Rows[0]["InstallationName"].ToString());
|
|
|
|
|
ws.GetRow(rowIndex + 2).GetCell(16).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Justify, 10, true, false);
|
|
|
|
|
|
|
|
|
|
//行3
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 3, rowIndex + 3, 16, 20);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 3).GetCell(16).SetCellValue("");
|
|
|
|
|
ws.GetRow(rowIndex + 3).GetCell(16).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Justify, 10, true, false);
|
|
|
|
|
|
|
|
|
|
//行4
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 0, 1);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(0).SetCellValue("检测方法");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 2, 3);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(2).SetCellValue(tbTitle.Rows[0]["DetectionTypeCode"].ToString());
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 4, 6);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(4).SetCellValue("检测标准");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 7, 9);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(7).SetCellValue("GB 50184-2011");
|
|
|
|
|
//ws.GetRow(rowIndex + 4).GetCell(7).SetCellValue(tbTitle.Rows[0]["ExecStandard"].ToString());
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 10, 11);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(10).SetCellValue("检测比列");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 12, 14);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(12).SetCellValue(tbTitle.Rows[0]["DetectionRateCode"].ToString());
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 15, 17);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(15).SetCellValue("委托编号");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 18, 20);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(18).SetCellValue(tbTitle.Rows[0]["TrustBatchCode"].ToString());
|
|
|
|
|
|
|
|
|
|
//行5
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(0).SetCellValue("序号");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 1, 2);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(1).SetCellValue("检件编号");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 3, 5);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(3).SetCellValue("检件名称");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 6, 7);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(6).SetCellValue("质量证明文件编号");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 8, 10);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(8).SetCellValue("炉/批号");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 11, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(11).SetCellValue("检件规格");
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(13).SetCellValue("检件材质");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 14, 16);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(14).SetCellValue("热处理状态");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 17, 18);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(17).SetCellValue("制造/验收标准");
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(19).SetCellValue("总数量(道)");
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(20).SetCellValue("抽检数量");
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 表格
|
|
|
|
|
|
|
|
|
|
ws = ClExcelCreateRow(ws, hssfworkbook, rowIndex + 6, rowIndex + 20, style, 0, 20);
|
|
|
|
|
var dataTit = rowIndex + 6;
|
|
|
|
|
var tIndex = 5 + 15;
|
|
|
|
|
var dStart = 0;
|
|
|
|
|
var dEnd = 0;
|
|
|
|
|
if (i == 1)
|
|
|
|
|
{
|
|
|
|
|
dStart = 0;
|
|
|
|
|
dEnd = 15;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dStart = i == 2 ? 15 : ((i - 2) * 15) + 15;
|
|
|
|
|
dEnd = ((i - 1) * 15) + 15;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//合并单元格
|
|
|
|
|
for (int hb = dataTit; hb <= rowIndex + tIndex; hb++)
|
|
|
|
|
{
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 1, 2);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 3, 5);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 6, 7);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 8, 10);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 11, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 14, 16);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 17, 18);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取当前页数据
|
|
|
|
|
var pageTb = GetPageToTable(tb, dStart, dEnd);
|
|
|
|
|
for (int j = 0; j < pageTb.Rows.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
int dataIndex = dataTit + j;
|
|
|
|
|
//序号
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(0).SetCellValue(pageTb.Rows[j]["Number"].ToString());
|
|
|
|
|
//检件编号
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(1).SetCellValue(pageTb.Rows[j]["PipelineCode"].ToString() + " " + pageTb.Rows[j]["WeldJointCode"].ToString());
|
|
|
|
|
//检件名称
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(3).SetCellValue("焊缝");
|
|
|
|
|
//质量证明文件编号
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(6).SetCellValue(tbTitle.Rows[0]["QuaCertFile"].ToString());
|
|
|
|
|
//炉/批号
|
|
|
|
|
List<string> lpls = new List<string>();
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(pageTb.Rows[0]["HeartNo1"].ToString())) lpls.Add(pageTb.Rows[0]["HeartNo1"].ToString());
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(pageTb.Rows[0]["HeartNo2"].ToString())) lpls.Add(pageTb.Rows[0]["HeartNo2"].ToString());
|
|
|
|
|
if (lpls.Count > 0) lpls = lpls.GroupBy(x => x).Select(x => x.Key).ToList();
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(8).SetCellValue(string.Join("/", lpls));
|
|
|
|
|
//检件规格
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(11).SetCellValue(pageTb.Rows[j]["Specification"].ToString());
|
|
|
|
|
//检件材质
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(13).SetCellValue(pageTb.Rows[j]["MaterialCode"].ToString());
|
|
|
|
|
//热处理状态
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(14).SetCellValue(pageTb.Rows[j]["IsHotProessName"].ToString());
|
|
|
|
|
//制造/验收标准
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(17).SetCellValue(tbTitle.Rows[0]["AcceptStandard"].ToString());
|
|
|
|
|
//总数量(道)
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(19).SetCellValue("");
|
|
|
|
|
//抽检数量
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(20).SetCellValue("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rowIndex += tIndex;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 尾部
|
|
|
|
|
|
|
|
|
|
ws = ClExcelCreateRow(ws, hssfworkbook, rowIndex + 1, rowIndex + 8, style, 0, 20);
|
|
|
|
|
//合并单元格
|
|
|
|
|
for (int hb = rowIndex + 1; hb <= rowIndex + 8; hb++)
|
|
|
|
|
{
|
|
|
|
|
for (int c = 0; c <= 20; c++)
|
|
|
|
|
{
|
|
|
|
|
if (hb >= rowIndex + 2 && hb < rowIndex + 8)
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(hb).GetCell(c).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Left, 10, true, false);
|
|
|
|
|
}
|
|
|
|
|
if (hb == rowIndex + 8)
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(hb).GetCell(c).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Right, 10, true, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 0, 3);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 4, 8);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 9, 11);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 12, 17);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 18, 20);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//尾部行1
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(0).SetCellValue("检测单位");
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(4).SetCellValue("监理单位");
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(9).SetCellValue("管理公司");
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(12).SetCellValue("建设单位");
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(18).SetCellValue("检测单位");
|
|
|
|
|
//尾部行2
|
|
|
|
|
ws.GetRow(rowIndex + 2).GetCell(0).SetCellValue("质量检测员:");
|
|
|
|
|
ws.GetRow(rowIndex + 2).GetCell(4).SetCellValue("专业工程师:");
|
|
|
|
|
ws.GetRow(rowIndex + 2).GetCell(9).SetCellValue("专业/质量工程师:");
|
|
|
|
|
ws.GetRow(rowIndex + 2).GetCell(12).SetCellValue("业主代表:");
|
|
|
|
|
ws.GetRow(rowIndex + 2).GetCell(18).SetCellValue("接收人:");
|
|
|
|
|
//尾部行4
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(0).SetCellValue("专业工程师:");
|
|
|
|
|
//尾部行8
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(0).SetCellValue("年 月 日");
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(4).SetCellValue("年 月 日");
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(9).SetCellValue("年 月 日");
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(12).SetCellValue("年 月 日");
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(18).SetCellValue("年 月 日");
|
2024-06-24 17:41:45 +08:00
|
|
|
|
//插入签名图片
|
|
|
|
|
if (!string.IsNullOrEmpty(getJLInfo.Item1))
|
|
|
|
|
{
|
|
|
|
|
InsertImage(hssfworkbook, ws, rowIndex + 6, 2, rowIndex + 6, 4, Server.MapPath(getJLInfo.Item1), 1, 1, 10);
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(getGLGSInfo.Item1))
|
|
|
|
|
{
|
|
|
|
|
InsertImage(hssfworkbook, ws, rowIndex + 6, 5, rowIndex + 6, 6, Server.MapPath(getJLInfo.Item1), 1, 8);
|
|
|
|
|
}
|
2024-05-08 10:02:08 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
ws = ClExcelCreateRow(ws, hssfworkbook, rowIndex + 9, rowIndex + 9, style, 0, 20, false, true);
|
|
|
|
|
rowIndex += 10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (hssfworkbook.GetSheet("无损检测委托单") != null)
|
|
|
|
|
{
|
|
|
|
|
ws = (XSSFSheet)hssfworkbook.GetSheet("无损检测委托单");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rowIndex = 0;
|
|
|
|
|
ws = (XSSFSheet)hssfworkbook.CreateSheet("无损检测委托单");
|
|
|
|
|
|
|
|
|
|
#region 列宽
|
|
|
|
|
|
|
|
|
|
ws.SetColumnWidth(0, 9 * 256);
|
|
|
|
|
ws.SetColumnWidth(1, 6 * 256);
|
|
|
|
|
ws.SetColumnWidth(2, 6 * 256);
|
|
|
|
|
ws.SetColumnWidth(3, 6 * 256);
|
|
|
|
|
ws.SetColumnWidth(4, 6 * 256);
|
|
|
|
|
ws.SetColumnWidth(5, 9 * 256);
|
|
|
|
|
ws.SetColumnWidth(6, 9 * 256);
|
|
|
|
|
ws.SetColumnWidth(7, 5 * 256);
|
|
|
|
|
ws.SetColumnWidth(8, 5 * 256);
|
|
|
|
|
ws.SetColumnWidth(9, 5 * 256);
|
|
|
|
|
ws.SetColumnWidth(10, 8 * 256);
|
|
|
|
|
ws.SetColumnWidth(11, 9 * 256);
|
|
|
|
|
ws.SetColumnWidth(12, 11 * 256);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tb.Rows.Count > 0 && tbTitle.Rows.Count > 0)
|
|
|
|
|
{
|
2024-06-24 17:41:45 +08:00
|
|
|
|
string jlAuditer = tb.Rows[0]["JLAuditID"].ToString();
|
|
|
|
|
string glgsAuditer = tb.Rows[0]["GLGSAuditID"].ToString();
|
|
|
|
|
var getJLInfo = BLL.Sys_UserService.GetSingtrueImageUrl(jlAuditer);
|
|
|
|
|
var getGLGSInfo = BLL.Sys_UserService.GetSingtrueImageUrl(glgsAuditer);
|
|
|
|
|
|
2024-05-08 10:02:08 +08:00
|
|
|
|
var tbNum = tb.Rows.Count;
|
|
|
|
|
var pageNum =
|
|
|
|
|
tbNum < 15 ? 1
|
|
|
|
|
: Math.Ceiling((float)(tbNum - 14) / 14) + 1;
|
|
|
|
|
|
|
|
|
|
//循环页
|
|
|
|
|
for (int i = 1; i <= pageNum; i++)
|
|
|
|
|
{
|
|
|
|
|
#region 头部
|
|
|
|
|
|
|
|
|
|
ws = WsExcelCreateRow(ws, hssfworkbook, rowIndex, rowIndex + 12, style, 0, 12, 1);
|
|
|
|
|
//行0
|
|
|
|
|
CellRangeAddress region = new CellRangeAddress(rowIndex, rowIndex + 3, 0, 2);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(0).SetCellValue(tbTitle.Rows[0]["PipelineCode"].ToString());
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(0).CellStyle = style;
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(1).CellStyle = style;
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(2).CellStyle = style;
|
|
|
|
|
|
|
|
|
|
region = new CellRangeAddress(rowIndex, rowIndex + 3, 3, 9);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(3).SetCellValue("无损检测委托单");
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(3).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 16, true, true);
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(4).CellStyle = style;
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(5).CellStyle = style;
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(6).CellStyle = style;
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(7).CellStyle = style;
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(8).CellStyle = style;
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(9).CellStyle = style;
|
|
|
|
|
|
|
|
|
|
region = new CellRangeAddress(rowIndex, rowIndex, 10, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(10).SetCellValue(tbTitle.Rows[0]["ProjectName"].ToString());
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(10).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Justify, 10.5, true, false);
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(11).CellStyle = styleButton;
|
|
|
|
|
ws.GetRow(rowIndex).GetCell(12).CellStyle = styleButton;
|
|
|
|
|
|
|
|
|
|
//行1
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 10, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(10).SetCellValue("EnProjectName");
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(10).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Justify, 10.5, true, false);
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(11).CellStyle = styleNone;
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(12).CellStyle = styleNone;
|
|
|
|
|
|
|
|
|
|
//行2
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 2, rowIndex + 2, 10, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 2).GetCell(10).SetCellValue(tbTitle.Rows[0]["WorkAreaName"].ToString());
|
|
|
|
|
ws.GetRow(rowIndex + 2).GetCell(10).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Justify, 10.5, true, false);
|
|
|
|
|
ws.GetRow(rowIndex + 2).GetCell(11).CellStyle = styleNone;
|
|
|
|
|
ws.GetRow(rowIndex + 2).GetCell(12).CellStyle = styleNone;
|
|
|
|
|
|
|
|
|
|
//行3
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 3, rowIndex + 3, 10, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 3).GetCell(10).SetCellValue("EnWorkAreaName");
|
|
|
|
|
ws.GetRow(rowIndex + 3).GetCell(10).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Justify, 10.5, true, false);
|
|
|
|
|
ws.GetRow(rowIndex + 3).GetCell(11).CellStyle = styleTop;
|
|
|
|
|
ws.GetRow(rowIndex + 3).GetCell(12).CellStyle = styleTop;
|
|
|
|
|
|
|
|
|
|
//行4
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(0).SetCellValue("委托单位");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 1, 5);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(1).SetCellValue(tbTitle.Rows[0]["TrustUnit"].ToString());
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 6, 7);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(6).SetCellValue("委托编号");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 8, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(8).SetCellValue(tbTitle.Rows[0]["TrustBatchCode"].ToString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//行5,
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(0).SetCellValue("检测单位");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 1, 5);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(1).SetCellValue(tbTitle.Rows[0]["NDEUnit"].ToString());
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 6, 7);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(6).SetCellValue("检测方法");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 8, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 5).GetCell(8).SetCellValue(detectionTypeCode);
|
|
|
|
|
|
|
|
|
|
//行6
|
|
|
|
|
ws.GetRow(rowIndex + 6).GetCell(0).SetCellValue("检件名称");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 6, rowIndex + 6, 1, 5);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 6).GetCell(1).SetCellValue("管道焊缝");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 6, rowIndex + 6, 6, 7);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 6).GetCell(6).SetCellValue("表面状态");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 6, rowIndex + 6, 8, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 6).GetCell(8).SetCellValue(tbTitle.Rows[0]["SurfaceState"].ToString());
|
|
|
|
|
|
|
|
|
|
//行7
|
|
|
|
|
ws.GetRow(rowIndex + 7).GetCell(0).SetCellValue("检测标准");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 7, rowIndex + 7, 1, 5);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
//ws.GetRow(rowIndex + 8).GetCell(1).SetCellValue(tbTitle.Rows[0]["ExecStandard"].ToString());
|
|
|
|
|
ws.GetRow(rowIndex + 7).GetCell(1).SetCellValue(tbTitle.Rows[0]["TestStandard"].ToString());
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 7, rowIndex + 7, 6, 7);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 7).GetCell(6).SetCellValue("检测比例");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 7, rowIndex + 7, 8, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 7).GetCell(8).SetCellValue(tbTitle.Rows[0]["DetectionRateCode"].ToString());
|
|
|
|
|
|
|
|
|
|
//行8
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(0).SetCellValue("技术等级");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 8, rowIndex + 8, 1, 5);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(1).SetCellValue(tbTitle.Rows[0]["TechLevel"].ToString());
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 8, rowIndex + 8, 6, 7);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(6).SetCellValue("合格级别");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 8, rowIndex + 8, 8, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(8).SetCellValue(tbTitle.Rows[0]["QueClass"].ToString());
|
|
|
|
|
|
|
|
|
|
//行9
|
|
|
|
|
ws.GetRow(rowIndex + 9).GetCell(0).SetCellValue("焊接方法");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 9, rowIndex + 9, 1, 5);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 9).GetCell(1).SetCellValue(tbTitle.Rows[0]["WeldingMethodCode"].ToString());
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 9, rowIndex + 9, 6, 7);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 9).GetCell(6).SetCellValue("压力管道分级");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 9, rowIndex + 9, 8, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 9).GetCell(8).SetCellValue(tbTitle.Rows[0]["PIPClassCode"].ToString());
|
|
|
|
|
//ws.GetRow(rowIndex + 9).GetCell(1).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Justify, 10.5, true, false);
|
|
|
|
|
|
|
|
|
|
//行10
|
|
|
|
|
ws.GetRow(rowIndex + 10).GetCell(0).SetCellValue("坡口形式");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 10, rowIndex + 10, 1, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 10).GetCell(1).SetCellValue(tbTitle.Rows[0]["GrooveTypeCode"].ToString());
|
|
|
|
|
ws.GetRow(rowIndex + 10).GetCell(1).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Justify, 10.5, true, false);
|
|
|
|
|
|
|
|
|
|
//行11
|
|
|
|
|
ws.GetRow(rowIndex + 11).GetCell(0).SetCellValue("检测时机");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 11, rowIndex + 11, 1, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 11).GetCell(1).SetCellValue(tbTitle.Rows[0]["DetectionTiming"].ToString());
|
|
|
|
|
ws.GetRow(rowIndex + 11).GetCell(1).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Justify, 10.5, true, false);
|
|
|
|
|
|
|
|
|
|
//行12
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 12, rowIndex + 12, 0, 1);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 12).GetCell(0).SetCellValue("检件编号");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 12, rowIndex + 12, 2, 3);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 12).GetCell(2).SetCellValue("焊口号");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 12, rowIndex + 12, 4, 5);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 12).GetCell(4).SetCellValue("焊工代号");
|
|
|
|
|
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 12, rowIndex + 12, 6, 9);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 12).GetCell(6).SetCellValue("检件材质");
|
|
|
|
|
region = new CellRangeAddress(rowIndex + 12, rowIndex + 12, 10, 11);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
ws.GetRow(rowIndex + 12).GetCell(10).SetCellValue("检件规格(mm)");
|
|
|
|
|
ws.GetRow(rowIndex + 12).GetCell(12).SetCellValue("备注");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 表格
|
|
|
|
|
ws = WsExcelCreateRow(ws, hssfworkbook, rowIndex + 13, rowIndex + 26, style, 0, 12, 2);
|
|
|
|
|
var dataTit = rowIndex + 13;
|
|
|
|
|
var tIndex = 12 + 14;
|
|
|
|
|
var dStart = 0;
|
|
|
|
|
var dEnd = 0;
|
|
|
|
|
if (i == 1)
|
|
|
|
|
{
|
|
|
|
|
dStart = 0;
|
|
|
|
|
dEnd = 14;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dStart = i == 2 ? 14 : ((i - 2) * 14) + 14;
|
|
|
|
|
dEnd = ((i - 1) * 14) + 14;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//合并单元格
|
|
|
|
|
for (int hb = dataTit; hb <= rowIndex + tIndex; hb++)
|
|
|
|
|
{
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 0, 1);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 2, 3);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 4, 5);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 6, 9);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 10, 11);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
}
|
|
|
|
|
//获取当前页数据
|
|
|
|
|
var pageTb = GetPageToTable(tb, dStart, dEnd);
|
|
|
|
|
for (int j = 0; j < pageTb.Rows.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
int dataIndex = dataTit + j;
|
|
|
|
|
//检件编号
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(0).SetCellValue(pageTb.Rows[j]["PipelineCode"].ToString());
|
|
|
|
|
//焊口号
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(2).SetCellValue(pageTb.Rows[j]["WeldJointCode"].ToString());
|
|
|
|
|
//焊工代号
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(4).SetCellValue(pageTb.Rows[j]["WelderCode"].ToString());
|
|
|
|
|
//检件材质
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(6).SetCellValue(pageTb.Rows[j]["MaterialCode"].ToString());
|
|
|
|
|
//检件规格(mm)
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(10).SetCellValue(pageTb.Rows[j]["Specification"].ToString());
|
|
|
|
|
//备注
|
|
|
|
|
ws.GetRow(dataIndex).GetCell(12).SetCellValue(pageTb.Rows[j]["Remark"].ToString());
|
|
|
|
|
}
|
|
|
|
|
if (dataTit + pageTb.Rows.Count < 26)
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(dataTit + pageTb.Rows.Count).GetCell(0).SetCellValue("以下空白");
|
|
|
|
|
}
|
|
|
|
|
rowIndex += tIndex;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 尾部
|
2024-05-09 18:41:24 +08:00
|
|
|
|
string JLAudit = ""; //tb.Rows[0]["JLAudit"].ToString();
|
|
|
|
|
string GLGSAudit = ""; //tb.Rows[0]["GLGSAudit"].ToString();
|
2024-05-08 10:02:08 +08:00
|
|
|
|
ws = WsExcelCreateRow(ws, hssfworkbook, rowIndex + 1, rowIndex + 9, style, 0, 12, 3);
|
|
|
|
|
//合并单元格
|
|
|
|
|
for (int hb = rowIndex + 1; hb <= rowIndex + 10; hb++)
|
|
|
|
|
{
|
|
|
|
|
for (int c = 0; c <= 12; c++)
|
|
|
|
|
{
|
|
|
|
|
if (hb >= rowIndex + 2 && hb <= rowIndex + 3)
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(hb).GetCell(c).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Left, 10.5, true, false);
|
|
|
|
|
}
|
|
|
|
|
if (hb >= rowIndex + 4 && hb <= rowIndex + 8)
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(hb).GetCell(c).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Right, 10.5, true, false);
|
|
|
|
|
}
|
|
|
|
|
if (hb == rowIndex + 9)
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(hb).GetCell(c).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Center, 10.5, true, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 0, 1);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 2, 4);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 5, 6);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 7, 10);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
region = new CellRangeAddress(hb, hb, 11, 12);
|
|
|
|
|
ws.AddMergedRegion(region);
|
|
|
|
|
}
|
|
|
|
|
//尾部行1
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(0).SetCellValue("施工单位");
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(2).SetCellValue("监理单位");
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(5).SetCellValue("管理公司");
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(7).SetCellValue("建设单位");
|
|
|
|
|
ws.GetRow(rowIndex + 1).GetCell(11).SetCellValue("检测单位");
|
|
|
|
|
//尾部行3
|
|
|
|
|
ws.GetRow(rowIndex + 3).GetCell(0).SetCellValue("质量检测员:");
|
|
|
|
|
ws.GetRow(rowIndex + 3).GetCell(2).SetCellValue("专业工程师:");
|
|
|
|
|
ws.GetRow(rowIndex + 3).GetCell(5).SetCellValue("专业/质量工程师:");
|
|
|
|
|
ws.GetRow(rowIndex + 3).GetCell(7).SetCellValue("业主代表:");
|
|
|
|
|
ws.GetRow(rowIndex + 3).GetCell(11).SetCellValue("接收人:");
|
|
|
|
|
//尾部行4
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(2).SetCellValue(JLAudit);
|
|
|
|
|
ws.GetRow(rowIndex + 4).GetCell(3).SetCellValue(GLGSAudit);
|
|
|
|
|
//尾部行6
|
|
|
|
|
ws.GetRow(rowIndex + 6).GetCell(0).SetCellValue("专业工程师:");
|
|
|
|
|
//尾部行8
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(0).SetCellValue(" 年 月 日");
|
|
|
|
|
if (trustDate != null)
|
|
|
|
|
{
|
|
|
|
|
string tdate = trustDate.Value.Year + "年" + trustDate.Value.Month + "月" + trustDate.Value.Day + "日";
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(2).SetCellValue(tdate);
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(5).SetCellValue(tdate);
|
|
|
|
|
}
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(7).SetCellValue(" 年 月 日");
|
|
|
|
|
ws.GetRow(rowIndex + 8).GetCell(11).SetCellValue(" 年 月 日");
|
|
|
|
|
//尾部行9
|
|
|
|
|
|
2024-06-24 17:41:45 +08:00
|
|
|
|
//插入签名图片
|
|
|
|
|
if (!string.IsNullOrEmpty(getJLInfo.Item1))
|
|
|
|
|
{
|
|
|
|
|
InsertImage(hssfworkbook, ws, rowIndex + 6, 2, rowIndex + 6, 4, Server.MapPath(getJLInfo.Item1), 1, 1, 10);
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(getGLGSInfo.Item1))
|
|
|
|
|
{
|
|
|
|
|
InsertImage(hssfworkbook, ws, rowIndex + 6, 5, rowIndex + 6, 6, Server.MapPath(getJLInfo.Item1), 1, 8);
|
|
|
|
|
}
|
2024-05-08 10:02:08 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
ws = WsExcelCreateRow(ws, hssfworkbook, rowIndex + 11, rowIndex + 11, style, 0, 12, 3, true);
|
|
|
|
|
rowIndex += 11;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((int)(90 * (num) / totalNum) > percent)
|
|
|
|
|
{
|
|
|
|
|
percent = (int)(100 * (num) / totalNum);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
num++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ws.SetMargin(MarginType.LeftMargin, 0.3);
|
|
|
|
|
ws.SetMargin(MarginType.RightMargin, 0.2);
|
|
|
|
|
ws.SetMargin(MarginType.BottomMargin, 0.4);
|
|
|
|
|
|
|
|
|
|
ws.PrintSetup.Landscape = false;
|
|
|
|
|
ws.PrintSetup.PaperSize = 9;
|
|
|
|
|
ws.ForceFormulaRecalculation = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (FileStream filess = System.IO.File.OpenWrite(ReportFileName))
|
|
|
|
|
{
|
|
|
|
|
hssfworkbook.Write(filess);
|
|
|
|
|
//hssfworkbook.Close();
|
|
|
|
|
//filess.Flush();
|
|
|
|
|
//filess.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
percent = 100;
|
|
|
|
|
url = ReportFileName.Replace(Server.MapPath("~/"), "");
|
|
|
|
|
|
|
|
|
|
//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();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 私有方法
|
2024-06-24 17:41:45 +08:00
|
|
|
|
private void InsertImage(XSSFWorkbook hssfworkbook, XSSFSheet ws, int row1, int col1, int row2, int col2, string img, double w, double h, int dx1 = 0, int dy1 = 0, int dx2 = 0, int dy2 = 0)
|
|
|
|
|
{
|
|
|
|
|
int pictureIdx = hssfworkbook.AddPicture(System.IO.File.ReadAllBytes(img), PictureType.PNG);
|
|
|
|
|
IDrawing drawing = ws.CreateDrawingPatriarch();
|
|
|
|
|
IClientAnchor anchor = new XSSFClientAnchor(dx1 * XSSFShape.EMU_PER_PIXEL, dy1 * XSSFShape.EMU_PER_POINT, dx2 * XSSFShape.EMU_PER_PIXEL, dy2 * XSSFShape.EMU_PER_POINT, col1, row1, col2, row2);
|
|
|
|
|
IDrawing patriarch = ws.CreateDrawingPatriarch();
|
|
|
|
|
IPicture pict = (XSSFPicture)patriarch.CreatePicture(anchor, pictureIdx);
|
|
|
|
|
pict.Resize(w, h);
|
2024-05-08 10:02:08 +08:00
|
|
|
|
|
2024-06-24 17:41:45 +08:00
|
|
|
|
}
|
2024-05-08 10:02:08 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取某一列的所有值
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">列数据类型</typeparam>
|
|
|
|
|
/// <param name="dtSource">数据表</param>
|
|
|
|
|
/// <param name="filedName">列名</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<T> GetColumnValues<T>(DataTable dtSource, string filedName)
|
|
|
|
|
{
|
|
|
|
|
return (from r in dtSource.AsEnumerable() select r.Field<T>(filedName)).ToList<T>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 无损检测委托单行和列
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private XSSFSheet WsExcelCreateRow(XSSFSheet ws, XSSFWorkbook hssfworkbook, int sRows, int eRows, ICellStyle style, int cStart, int cEnd, int excelpart, bool isnobk = false)
|
|
|
|
|
{
|
|
|
|
|
for (int i = sRows; i <= eRows; i++)
|
|
|
|
|
{
|
|
|
|
|
ws.CreateRow(i);
|
|
|
|
|
if (excelpart == 1)
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(i).HeightInPoints =
|
|
|
|
|
i == sRows ? 27.75f :
|
|
|
|
|
i == (sRows + 1) ? 25.5f :
|
|
|
|
|
i == (sRows + 2) ? 25.5f :
|
|
|
|
|
i == (sRows + 3) ? 25.5f :
|
|
|
|
|
i == (sRows + 4) ? 23.25f :
|
|
|
|
|
i == (sRows + 5) ? 23.25f :
|
|
|
|
|
i == (sRows + 6) ? 23.25f :
|
|
|
|
|
i == (sRows + 7) ? 23.25f :
|
|
|
|
|
i == (sRows + 8) ? 23.25f :
|
|
|
|
|
i == (sRows + 9) ? 23.25f :
|
|
|
|
|
i == (sRows + 10) ? 23.25f :
|
|
|
|
|
i == (sRows + 11) ? 23.25f :
|
|
|
|
|
i == (sRows + 12) ? 23.25f :
|
|
|
|
|
17f;
|
|
|
|
|
}
|
|
|
|
|
else if (excelpart == 2)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ws.GetRow(i).HeightInPoints = 25.5f;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(i).HeightInPoints = 15.5f;
|
|
|
|
|
}
|
|
|
|
|
for (int j = cStart; j <= cEnd; j++)
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(i).CreateCell(j);
|
|
|
|
|
if (isnobk)
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(i).GetCell(j).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.None, BorderStyle.None, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Center, 10.5, true, false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(i).GetCell(j).CellStyle = style;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ws;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 材料及配件检测委托单行和列
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private XSSFSheet ClExcelCreateRow(XSSFSheet ws, XSSFWorkbook hssfworkbook, int sRows, int eRows, ICellStyle style, int cStart, int cEnd, bool istitle = false, bool isnobk = false)
|
|
|
|
|
{
|
|
|
|
|
for (int i = sRows; i <= eRows; i++)
|
|
|
|
|
{
|
|
|
|
|
ws.CreateRow(i);
|
|
|
|
|
if (istitle)
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(i).HeightInPoints =
|
|
|
|
|
i == sRows ? 27.75f :
|
|
|
|
|
i == (sRows + 1) ? 25f :
|
|
|
|
|
i == (sRows + 2) ? 21.75f :
|
|
|
|
|
i == (sRows + 3) ? 21.75f :
|
|
|
|
|
i == (sRows + 5) ? 28f :
|
|
|
|
|
14.75f;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(i).HeightInPoints = 14.75f;
|
|
|
|
|
}
|
|
|
|
|
for (int j = cStart; j <= cEnd; j++)
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(i).CreateCell(j);
|
|
|
|
|
if (isnobk)
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(i).GetCell(j).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.None, BorderStyle.None, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ws.GetRow(i).GetCell(j).CellStyle = style;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ws;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询指定条数分页
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|