2024-06-21 16:37:50 +08:00
using System ;
2024-05-11 15:22:08 +08:00
using System.Collections.Generic ;
using System.Data ;
2024-06-21 16:37:50 +08:00
using System.Data.SqlClient ;
using System.IO ;
2024-05-11 15:22:08 +08:00
using System.Linq ;
2024-06-21 16:37:50 +08:00
using System.Web ;
using BLL ;
using Model ;
using NPOI.HSSF.Util ;
2024-06-20 17:12:59 +08:00
using NPOI.SS.UserModel ;
2024-06-21 16:37:50 +08:00
using NPOI.SS.Util ;
2024-06-20 17:12:59 +08:00
using NPOI.XSSF.UserModel ;
2024-05-11 15:22:08 +08:00
namespace FineUIPro.Web.WeldingProcess.PMI
{
public partial class PMIDelegation : PageBase
{
#region 定 义 项
/// <summary>
/// PMI委托主键
/// </summary>
public string PMIDelegationId
{
get
{
return ( string ) ViewState [ "PMIDelegationId" ] ;
}
set
{
ViewState [ "PMIDelegationId" ] = value ;
}
}
#endregion
#region 加 载 页 面
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
this . ddlPageSize . SelectedValue = this . Grid1 . PageSize . ToString ( ) ;
this . PMIDelegationId = string . Empty ;
this . InitTreeMenu ( ) ; //加载树
}
}
#endregion
#region 加 载 树
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu ( )
{
string projectName = string . Empty ;
var pro = BLL . Base_ProjectService . GetProjectByProjectId ( this . CurrUser . LoginProjectId ) ;
if ( pro ! = null )
{
this . tvControlItem . Nodes . Clear ( ) ;
TreeNode rootNode = new TreeNode ( ) ;
rootNode . Text = "[" + pro . ProjectCode + "]" + pro . ProjectName ;
rootNode . NodeID = "0" ;
rootNode . Expanded = true ;
rootNode . EnableClickEvent = true ;
this . tvControlItem . Nodes . Add ( rootNode ) ;
List < Model . PMI_Delegation > trustLists = new List < Model . PMI_Delegation > ( ) ; ///PMI委托单
2024-06-21 16:37:50 +08:00
2024-05-11 15:22:08 +08:00
if ( ! string . IsNullOrEmpty ( this . txtSearchNo . Text . Trim ( ) ) )
{
trustLists = ( from x in Funs . DB . PMI_Delegation where x . ProjectId = = CurrUser . LoginProjectId & & x . DelegationNo . Contains ( this . txtSearchNo . Text . Trim ( ) ) orderby x . DelegationNo select x ) . ToList ( ) ;
}
else
{
trustLists = ( from x in Funs . DB . PMI_Delegation where x . ProjectId = = CurrUser . LoginProjectId orderby x . DelegationNo select x ) . ToList ( ) ;
}
this . BindNodes ( rootNode , trustLists ) ;
}
}
#endregion
#region 绑 定 树 节 点
/// <summary>
/// 绑定树节点
/// </summary>
/// <param name="node"></param>
private void BindNodes ( TreeNode node , List < Model . PMI_Delegation > trustList )
{
foreach ( var item in trustList )
{
TreeNode newNode = new TreeNode ( ) ;
newNode . Text = item . DelegationNo ;
newNode . NodeID = item . Id ;
newNode . ToolTip = item . DelegationNo ;
newNode . CommandName = Resources . Lan . RequestSheetNumber ;
newNode . EnableClickEvent = true ;
node . Nodes . Add ( newNode ) ;
}
}
#endregion
#region 点 击 TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand ( object sender , TreeCommandEventArgs e )
{
if ( this . tvControlItem . SelectedNodeID ! = "0" )
{
this . PMIDelegationId = tvControlItem . SelectedNodeID ;
this . BindGrid ( ) ;
}
}
#endregion
#region DropDownList下拉选择事件
/// <summary>
/// 项目下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpProjectId_SelectedIndexChanged ( object sender , EventArgs e )
{
this . InitTreeMenu ( ) ;
}
#endregion
#region 数 据 绑 定
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid ( )
{
string strSql = string . Empty ;
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
this . SetTextTemp ( ) ;
this . PageInfoLoad ( ) ; ///页面输入提交信息
if ( ! string . IsNullOrEmpty ( this . tvControlItem . SelectedNodeID ) )
{
2024-06-21 16:37:50 +08:00
var result = Funs . DB . PMI_Delegation . FirstOrDefault ( t = > t . Id = = this . tvControlItem . SelectedNodeID ) ;
2024-05-11 15:22:08 +08:00
if ( result ! = null )
{
this . PMIDelegationId = result . Id ;
2024-05-12 12:05:01 +08:00
strSql = @"SELECT *FROM [View_PMI_DelegationDetails] WHERE ProjectId= @ProjectId AND PMIID=@PMIDelegationId " ;
2024-05-11 15:22:08 +08:00
listStr . Add ( new SqlParameter ( "@ProjectId" , result ! = null ? result . ProjectId : this . CurrUser . LoginProjectId ) ) ;
2024-05-12 12:05:01 +08:00
listStr . Add ( new SqlParameter ( "@PMIDelegationId" , this . PMIDelegationId ) ) ;
2024-05-11 15:22:08 +08:00
if ( ! string . IsNullOrEmpty ( this . txtIsoNo . Text . Trim ( ) ) )
{
2024-05-12 14:23:37 +08:00
strSql + = @" and PipelineCode like '%'+@PipelineCode+'%' " ;
2024-05-11 15:22:08 +08:00
listStr . Add ( new SqlParameter ( "@PipelineCode" , this . txtIsoNo . Text . Trim ( ) ) ) ;
}
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( strSql , parameter ) ;
// 2.获取当前分页数据
//var table = this.GetPagedDataTable(Grid1, tb1);
Grid1 . RecordCount = tb . Rows . Count ;
//tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this . GetPagedDataTable ( Grid1 , tb ) ;
Grid1 . DataSource = table ;
Grid1 . DataBind ( ) ;
}
}
}
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged ( object sender , EventArgs e )
{
this . BindGrid ( ) ;
}
#region 加 载 页 面 输 入 提 交 信 息
/// <summary>
/// 加载页面输入提交信息
/// </summary>
private void PageInfoLoad ( )
{
2024-06-21 16:37:50 +08:00
var trust = Funs . DB . PMI_Delegation . FirstOrDefault ( t = > t . Id = = this . PMIDelegationId ) ;
2024-05-11 15:22:08 +08:00
if ( trust ! = null )
{
this . txtDelegationNo . Text = trust . DelegationNo ;
if ( trust . DelegationDate . HasValue )
{
this . txtDelegationDate . Text = string . Format ( "{0:yyyy-MM-dd}" , trust . DelegationDate ) ;
}
if ( ! string . IsNullOrEmpty ( trust . InstallationId ) )
{
this . txtInstallationName . Text = BLL . Project_InstallationService . GetProject_InstallationNameByInstallationId ( trust . InstallationId ) ;
}
if ( ! string . IsNullOrEmpty ( trust . UnitId ) )
{
this . txtUnitName . Text = BLL . Base_UnitService . GetUnitNameByUnitId ( trust . UnitId ) ;
}
this . txtDetectionMethod . Text = "PMI光谱分析" ;
this . txtDetectionStandard . Text = trust . DetectionStandard ;
if ( ! string . IsNullOrEmpty ( trust . Tabler ) )
{
this . txtTabler . Text = BLL . Sys_UserService . GetUserNameByUserId ( trust . Tabler ) ;
}
this . txtRemark . Text = trust . Remark ;
}
}
#endregion
#region 清 空 文 本
/// <summary>
/// 清空文本
/// </summary>
private void SetTextTemp ( )
{
this . txtDelegationNo . Text = string . Empty ;
this . txtDelegationDate . Text = string . Empty ;
this . txtInstallationName . Text = string . Empty ;
this . txtUnitName . Text = string . Empty ;
this . txtDetectionMethod . Text = string . Empty ;
this . txtDetectionStandard . Text = string . Empty ;
this . txtTabler . Text = string . Empty ;
this . txtRemark . Text = string . Empty ;
}
#endregion
#endregion
#region 分 页 排 序
#region 页 索 引 改 变 事 件
/// <summary>
/// 页索引改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange ( object sender , GridPageEventArgs e )
{
BindGrid ( ) ;
}
#endregion
#region 排 序
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort ( object sender , GridSortEventArgs e )
{
BindGrid ( ) ;
}
#endregion
#region 分 页 选 择 下 拉 改 变 事 件
/// <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 ( ) ;
}
#endregion
#endregion
#region PMI委托 维 护 事 件
/// <summary>
/// 增加PMI委托
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNew_Click ( object sender , EventArgs e )
{
2024-06-11 17:27:06 +08:00
if ( CommonService . GetAllButtonPowerList ( this . CurrUser . LoginProjectId , this . CurrUser . UserId , Const . PMIDelegationMenuId , Const . BtnAdd ) )
2024-05-11 15:22:08 +08:00
{
this . SetTextTemp ( ) ;
2024-06-21 16:37:50 +08:00
string window = String . Format ( "PMIDelegationEdit.aspx?PMIDelegationId={0}" , string . Empty , "新增 - " ) ;
2024-05-12 15:49:21 +08:00
PageContext . RegisterStartupScript ( Window2 . GetSaveStateReference ( this . hdPMIDelegationId . ClientID )
2024-05-12 15:28:06 +08:00
+ Window2 . GetShowReference ( window ) ) ;
2024-05-11 15:22:08 +08:00
}
else
{
ShowNotify ( Resources . Lan . NoPrivilegePrompt , MessageBoxIcon . Warning ) ;
}
}
#region 编 辑 PMI委托
/// <summary>
/// 编辑PMI委托
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnEdit_Click ( object sender , EventArgs e )
{
if ( CommonService . GetAllButtonPowerList ( this . CurrUser . LoginProjectId , this . CurrUser . UserId , Const . HotProessTrustMenuId , Const . BtnSave ) )
{
2024-06-21 16:37:50 +08:00
var trustManage = Funs . DB . PMI_Delegation . FirstOrDefault ( t = > t . Id = = this . PMIDelegationId ) ;
2024-05-11 15:22:08 +08:00
if ( trustManage ! = null )
{
2024-05-12 15:49:21 +08:00
string openUrl = String . Format ( "PMIDelegationEdit.aspx?PMIDelegationId={0}" , this . PMIDelegationId , "编辑 - " ) ;
PageContext . RegisterStartupScript ( Window2 . GetSaveStateReference ( this . hdPMIDelegationId . ClientID )
+ Window2 . GetShowReference ( openUrl ) ) ;
2024-05-11 15:22:08 +08:00
}
else
{
2024-05-12 22:53:47 +08:00
ShowNotify ( "请选择要处理的PMI委托" , MessageBoxIcon . Warning ) ;
2024-05-11 15:22:08 +08:00
}
}
else
{
ShowNotify ( Resources . Lan . NoPrivilegePrompt , MessageBoxIcon . Warning ) ;
}
}
#endregion
#region 删 除 PMI委托
/// <summary>
/// 删除PMI委托
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDelete_Click ( object sender , EventArgs e )
{
2024-06-11 17:27:06 +08:00
if ( CommonService . GetAllButtonPowerList ( this . CurrUser . LoginProjectId , this . CurrUser . UserId , Const . PMIDelegationMenuId , Const . BtnDelete ) )
2024-05-11 15:22:08 +08:00
{
2024-06-21 16:37:50 +08:00
var trustManage = Funs . DB . PMI_Delegation . FirstOrDefault ( t = > t . Id = = this . PMIDelegationId ) ;
2024-05-11 15:22:08 +08:00
if ( trustManage ! = null )
2024-06-21 16:37:50 +08:00
{
2024-05-11 15:22:08 +08:00
//删除主表数据
Funs . DB . PMI_Delegation . DeleteOnSubmit ( trustManage ) ;
//删除 明细表
2024-05-12 22:53:47 +08:00
var details = Funs . DB . PMI_DelegationDetails . Where ( t = > t . PMIId = = trustManage . Id ) . ToList ( ) ;
Funs . DB . PMI_DelegationDetails . DeleteAllOnSubmit ( details ) ;
2024-05-11 15:22:08 +08:00
Funs . DB . SubmitChanges ( ) ;
Alert . ShowInTop ( Resources . Lan . DeletedSuccessfully , MessageBoxIcon . Success ) ;
this . InitTreeMenu ( ) ;
SetTextTemp ( ) ;
this . Grid1 . DataSource = null ;
this . Grid1 . DataBind ( ) ;
}
else
{
ShowNotify ( Resources . Lan . PleaseSelectDeleteHotProessTrust , MessageBoxIcon . Warning ) ;
}
}
else
{
ShowNotify ( Resources . Lan . NoPrivilegePrompt , MessageBoxIcon . Warning ) ;
return ;
}
}
#endregion
#endregion
#region 关 闭 弹 出 窗 口 及 刷 新 页 面
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
2024-05-12 15:49:21 +08:00
protected void Window2_Close ( object sender , WindowCloseEventArgs e )
2024-05-11 15:22:08 +08:00
{
this . InitTreeMenu ( ) ;
this . BindGrid ( ) ;
2024-06-21 16:37:50 +08:00
2024-05-11 15:22:08 +08:00
}
#region 查 询
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Tree_TextChanged ( object sender , EventArgs e )
{
this . InitTreeMenu ( ) ;
}
#endregion
#endregion
2024-06-21 16:37:50 +08:00
#region 获 取 按 钮 权 限
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private bool GetButtonPower ( string button )
2024-06-20 17:12:59 +08:00
{
2024-06-21 16:37:50 +08:00
return BLL . CommonService . GetAllButtonPowerList ( this . CurrUser . LoginProjectId , this . CurrUser . UserId , BLL . Const . DailyReportCompleteMenuId , button ) ;
2024-06-20 17:12:59 +08:00
}
2024-06-21 16:37:50 +08:00
#endregion
2024-06-20 17:12:59 +08:00
/// <summary>
2024-06-21 16:37:50 +08:00
/// 打印
2024-06-20 17:12:59 +08:00
/// </summary>
2024-06-21 16:37:50 +08:00
protected void btnExport_Click ( object sender , EventArgs e )
2024-06-20 17:12:59 +08:00
{
2024-06-21 16:37:50 +08:00
if ( string . IsNullOrWhiteSpace ( this . tvControlItem . SelectedNodeID ) )
{
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 + "out.xlsx" ;
int rowIndex = 0 ;
XSSFWorkbook hssfworkbook = new XSSFWorkbook ( ) ;
XSSFSheet ws = ( XSSFSheet ) hssfworkbook . CreateSheet ( "无损检测委托单(PMI)" ) ;
#region 列 宽
ws . SetColumnWidth ( 0 , 6 * 256 ) ;
ws . SetColumnWidth ( 1 , 4 * 256 ) ;
ws . SetColumnWidth ( 2 , 6 * 256 ) ;
ws . SetColumnWidth ( 3 , 6 * 256 ) ;
ws . SetColumnWidth ( 4 , 6 * 256 ) ;
ws . SetColumnWidth ( 5 , 6 * 256 ) ;
ws . SetColumnWidth ( 6 , 9 * 256 ) ;
ws . SetColumnWidth ( 7 , 9 * 256 ) ;
ws . SetColumnWidth ( 8 , 5 * 256 ) ;
ws . SetColumnWidth ( 9 , 5 * 256 ) ;
ws . SetColumnWidth ( 10 , 5 * 256 ) ;
ws . SetColumnWidth ( 11 , 8 * 256 ) ;
ws . SetColumnWidth ( 12 , 9 * 256 ) ;
ws . SetColumnWidth ( 13 , 11 * 256 ) ;
#endregion
string pmiId = this . tvControlItem . SelectedNodeID ;
//头部
var pmititle = Funs . DB . PMI_Delegation . FirstOrDefault ( x = > x . Id = = pmiId ) ;
//列表
List < SqlParameter > listStr = new List < SqlParameter > ( ) ;
listStr . Add ( new SqlParameter ( "@ProjectId" , pmititle ! = null ? pmititle . ProjectId : this . CurrUser . LoginProjectId ) ) ;
listStr . Add ( new SqlParameter ( "@PMIID" , this . PMIDelegationId ) ) ;
SqlParameter [ ] parameter = listStr . ToArray ( ) ;
var tb = SQLHelper . GetDataTableRunText ( "SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID" , parameter ) ;
//模拟多页数据sql
//var tb = SQLHelper.GetDataTableRunText("SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID union all SELECT * FROM View_PMI_DelegationDetails WHERE ProjectId=@ProjectId AND PMIID=@PMIID", parameter);
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 ( tb . Rows . Count > 0 & & pmititle ! = null )
{
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 , 13 , 1 ) ;
//行0
CellRangeAddress region = new CellRangeAddress ( rowIndex , rowIndex + 3 , 0 , 3 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex ) . GetCell ( 0 ) . SetCellValue ( "NDE-002" ) ;
ws . GetRow ( rowIndex ) . GetCell ( 0 ) . CellStyle = style ;
ws . GetRow ( rowIndex ) . GetCell ( 1 ) . CellStyle = style ;
ws . GetRow ( rowIndex ) . GetCell ( 2 ) . CellStyle = style ;
ws . GetRow ( rowIndex ) . GetCell ( 3 ) . CellStyle = style ;
region = new CellRangeAddress ( rowIndex , rowIndex + 3 , 4 , 10 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex ) . GetCell ( 4 ) . SetCellValue ( "无损检测委托单\r\nPMI" ) ;
ws . GetRow ( rowIndex ) . GetCell ( 4 ) . CellStyle = CommonPrint . SetExcelStyle ( hssfworkbook , BorderStyle . Thin , BorderStyle . Thin , BorderStyle . Thin , BorderStyle . Thin , VerticalAlignment . Center , HorizontalAlignment . Center , 16 , true , true ) ;
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 ;
ws . GetRow ( rowIndex ) . GetCell ( 10 ) . CellStyle = style ;
region = new CellRangeAddress ( rowIndex , rowIndex , 11 , 13 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex ) . GetCell ( 11 ) . SetCellValue ( "工程名称:巴斯夫(广东)一体化项目专用化学品二区" ) ;
ws . GetRow ( rowIndex ) . GetCell ( 11 ) . CellStyle = CommonPrint . SetExcelStyle ( hssfworkbook , BorderStyle . None , BorderStyle . Thin , BorderStyle . Thin , BorderStyle . Thin , VerticalAlignment . Center , HorizontalAlignment . Justify , 10.5 , true , false ) ;
ws . GetRow ( rowIndex ) . GetCell ( 12 ) . CellStyle = styleButton ;
ws . GetRow ( rowIndex ) . GetCell ( 13 ) . CellStyle = styleButton ;
//行1
region = new CellRangeAddress ( rowIndex + 1 , rowIndex + 1 , 11 , 13 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 1 ) . GetCell ( 11 ) . SetCellValue ( "BASF (Guangdong) Integrated Project Citral Cluster" ) ;
ws . GetRow ( rowIndex + 1 ) . GetCell ( 11 ) . 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 ( 12 ) . CellStyle = styleNone ;
ws . GetRow ( rowIndex + 1 ) . GetCell ( 13 ) . CellStyle = styleNone ;
//行2
region = new CellRangeAddress ( rowIndex + 2 , rowIndex + 2 , 11 , 13 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 2 ) . GetCell ( 11 ) . SetCellValue ( "单元名称:" ) ;
ws . GetRow ( rowIndex + 2 ) . GetCell ( 11 ) . 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 ( 12 ) . CellStyle = styleNone ;
ws . GetRow ( rowIndex + 2 ) . GetCell ( 13 ) . CellStyle = styleNone ;
//行3
region = new CellRangeAddress ( rowIndex + 3 , rowIndex + 3 , 11 , 13 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 3 ) . GetCell ( 11 ) . SetCellValue ( "Unit Name:" ) ;
ws . GetRow ( rowIndex + 3 ) . GetCell ( 11 ) . 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 ( 12 ) . CellStyle = styleTop ;
ws . GetRow ( rowIndex + 3 ) . GetCell ( 13 ) . CellStyle = styleTop ;
//行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 , 6 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 4 ) . GetCell ( 2 ) . SetCellValue ( "" ) ;
region = new CellRangeAddress ( rowIndex + 4 , rowIndex + 4 , 7 , 8 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 4 ) . GetCell ( 7 ) . SetCellValue ( "委托编号" ) ;
region = new CellRangeAddress ( rowIndex + 4 , rowIndex + 4 , 9 , 13 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 4 ) . GetCell ( 9 ) . SetCellValue ( "" ) ;
//行5
region = new CellRangeAddress ( rowIndex + 5 , rowIndex + 5 , 0 , 1 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 5 ) . GetCell ( 0 ) . SetCellValue ( "检测单位" ) ;
region = new CellRangeAddress ( rowIndex + 5 , rowIndex + 5 , 2 , 6 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 5 ) . GetCell ( 2 ) . SetCellValue ( "" ) ;
region = new CellRangeAddress ( rowIndex + 5 , rowIndex + 5 , 7 , 8 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 5 ) . GetCell ( 7 ) . SetCellValue ( "检测方法" ) ;
region = new CellRangeAddress ( rowIndex + 5 , rowIndex + 5 , 9 , 13 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 5 ) . GetCell ( 9 ) . SetCellValue ( "" ) ;
//行6
region = new CellRangeAddress ( rowIndex + 6 , rowIndex + 6 , 0 , 1 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 6 ) . GetCell ( 0 ) . SetCellValue ( "检件名称" ) ;
region = new CellRangeAddress ( rowIndex + 6 , rowIndex + 6 , 2 , 6 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 6 ) . GetCell ( 2 ) . SetCellValue ( "" ) ;
region = new CellRangeAddress ( rowIndex + 6 , rowIndex + 6 , 7 , 8 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 6 ) . GetCell ( 7 ) . SetCellValue ( "表面状态" ) ;
region = new CellRangeAddress ( rowIndex + 6 , rowIndex + 6 , 9 , 13 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 6 ) . GetCell ( 9 ) . SetCellValue ( "" ) ;
//行7
region = new CellRangeAddress ( rowIndex + 7 , rowIndex + 7 , 0 , 1 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 7 ) . GetCell ( 0 ) . SetCellValue ( "检测标准" ) ;
region = new CellRangeAddress ( rowIndex + 7 , rowIndex + 7 , 2 , 6 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 7 ) . GetCell ( 2 ) . SetCellValue ( "" ) ;
region = new CellRangeAddress ( rowIndex + 7 , rowIndex + 7 , 7 , 8 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 7 ) . GetCell ( 7 ) . SetCellValue ( "检测比例" ) ;
region = new CellRangeAddress ( rowIndex + 7 , rowIndex + 7 , 9 , 13 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 7 ) . GetCell ( 9 ) . SetCellValue ( "" ) ;
//行8
region = new CellRangeAddress ( rowIndex + 8 , rowIndex + 8 , 0 , 1 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 8 ) . GetCell ( 0 ) . SetCellValue ( "转动口/固定口" ) ;
region = new CellRangeAddress ( rowIndex + 8 , rowIndex + 8 , 2 , 6 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 8 ) . GetCell ( 2 ) . SetCellValue ( "" ) ;
region = new CellRangeAddress ( rowIndex + 8 , rowIndex + 8 , 7 , 8 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 8 ) . GetCell ( 7 ) . SetCellValue ( "委托日期" ) ;
region = new CellRangeAddress ( rowIndex + 8 , rowIndex + 8 , 9 , 13 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 8 ) . GetCell ( 9 ) . SetCellValue ( "" ) ;
//行9
region = new CellRangeAddress ( rowIndex + 9 , rowIndex + 9 , 0 , 1 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 9 ) . GetCell ( 0 ) . SetCellValue ( "焊接方法" ) ;
region = new CellRangeAddress ( rowIndex + 9 , rowIndex + 9 , 2 , 6 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 9 ) . GetCell ( 2 ) . SetCellValue ( "" ) ;
region = new CellRangeAddress ( rowIndex + 9 , rowIndex + 9 , 7 , 8 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 9 ) . GetCell ( 7 ) . SetCellValue ( "压力管道分级" ) ;
region = new CellRangeAddress ( rowIndex + 9 , rowIndex + 9 , 9 , 13 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 9 ) . GetCell ( 9 ) . SetCellValue ( "" ) ;
//行10
region = new CellRangeAddress ( rowIndex + 10 , rowIndex + 10 , 0 , 1 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 10 ) . GetCell ( 0 ) . SetCellValue ( "检测时机" ) ;
region = new CellRangeAddress ( rowIndex + 10 , rowIndex + 10 , 2 , 6 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 10 ) . GetCell ( 2 ) . SetCellValue ( "" ) ;
region = new CellRangeAddress ( rowIndex + 10 , rowIndex + 10 , 7 , 8 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 10 ) . GetCell ( 7 ) . SetCellValue ( "被检产品标准" ) ;
region = new CellRangeAddress ( rowIndex + 10 , rowIndex + 10 , 9 , 13 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 10 ) . GetCell ( 9 ) . SetCellValue ( "" ) ;
//行12
region = new CellRangeAddress ( rowIndex + 11 , rowIndex + 11 , 0 , 2 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 11 ) . GetCell ( 0 ) . SetCellValue ( "检件编号/管线号" ) ;
region = new CellRangeAddress ( rowIndex + 11 , rowIndex + 11 , 3 , 4 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 11 ) . GetCell ( 3 ) . SetCellValue ( "" ) ;
region = new CellRangeAddress ( rowIndex + 11 , rowIndex + 11 , 5 , 6 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 11 ) . GetCell ( 5 ) . SetCellValue ( "焊口总数" ) ;
region = new CellRangeAddress ( rowIndex + 11 , rowIndex + 11 , 7 , 9 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 11 ) . GetCell ( 7 ) . SetCellValue ( "" ) ;
region = new CellRangeAddress ( rowIndex + 11 , rowIndex + 11 , 10 , 11 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 11 ) . GetCell ( 10 ) . SetCellValue ( "抽检数量" ) ;
region = new CellRangeAddress ( rowIndex + 11 , rowIndex + 11 , 12 , 13 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 11 ) . GetCell ( 12 ) . SetCellValue ( "" ) ;
//行13
ws . GetRow ( rowIndex + 12 ) . GetCell ( 0 ) . SetCellValue ( "检测\r\n部位" ) ;
region = new CellRangeAddress ( rowIndex + 12 , rowIndex + 12 , 1 , 3 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 12 ) . GetCell ( 1 ) . SetCellValue ( "检件编号/管线号" ) ;
ws . GetRow ( rowIndex + 12 ) . GetCell ( 4 ) . SetCellValue ( "焊口号" ) ;
region = new CellRangeAddress ( rowIndex + 12 , rowIndex + 12 , 5 , 6 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 12 ) . GetCell ( 5 ) . SetCellValue ( "焊工代号" ) ;
region = new CellRangeAddress ( rowIndex + 12 , rowIndex + 12 , 7 , 10 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 12 ) . GetCell ( 7 ) . SetCellValue ( "检件材质" ) ;
region = new CellRangeAddress ( rowIndex + 12 , rowIndex + 12 , 11 , 12 ) ;
ws . AddMergedRegion ( region ) ;
ws . GetRow ( rowIndex + 12 ) . GetCell ( 11 ) . SetCellValue ( "检件规格(mm)" ) ;
ws . GetRow ( rowIndex + 12 ) . GetCell ( 13 ) . SetCellValue ( "备注" ) ;
#endregion
#region 表 格
ws = WsExcelCreateRow ( ws , hssfworkbook , rowIndex + 13 , rowIndex + 26 , style , 0 , 13 , 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 , 1 , 3 ) ;
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 ) ;
}
//获取当前页数据
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 ( "" ) ;
//检件编号/管线号
ws . GetRow ( dataIndex ) . GetCell ( 1 ) . SetCellValue ( "数据待绑定" ) ;
//焊口号
ws . GetRow ( dataIndex ) . GetCell ( 4 ) . SetCellValue ( "" ) ;
//焊工代号
ws . GetRow ( dataIndex ) . GetCell ( 5 ) . SetCellValue ( "" ) ;
//检件材质
ws . GetRow ( dataIndex ) . GetCell ( 7 ) . SetCellValue ( "" ) ;
//检件规格(mm)
ws . GetRow ( dataIndex ) . GetCell ( 11 ) . SetCellValue ( "" ) ;
//备注
ws . GetRow ( dataIndex ) . GetCell ( 13 ) . SetCellValue ( "" ) ;
}
if ( dataTit + pageTb . Rows . Count < 26 )
{
ws . GetRow ( dataTit + pageTb . Rows . Count ) . GetCell ( 0 ) . SetCellValue ( "以下空白" ) ;
}
rowIndex + = tIndex ;
#endregion
#region 尾 部
ws = WsExcelCreateRow ( ws , hssfworkbook , rowIndex + 1 , rowIndex + 9 , style , 0 , 13 , 3 ) ;
//合并单元格
for ( int hb = rowIndex + 1 ; hb < = rowIndex + 9 ; hb + + )
{
for ( int c = 0 ; c < = 13 ; 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 , 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 , 11 ) ;
ws . AddMergedRegion ( region ) ;
region = new CellRangeAddress ( hb , hb , 12 , 13 ) ;
ws . AddMergedRegion ( region ) ;
}
//尾部行1
ws . GetRow ( rowIndex + 1 ) . GetCell ( 0 ) . SetCellValue ( "施工单位" ) ;
ws . GetRow ( rowIndex + 1 ) . GetCell ( 3 ) . SetCellValue ( "监理单位" ) ;
ws . GetRow ( rowIndex + 1 ) . GetCell ( 6 ) . SetCellValue ( "管理公司" ) ;
ws . GetRow ( rowIndex + 1 ) . GetCell ( 8 ) . SetCellValue ( "建设单位" ) ;
ws . GetRow ( rowIndex + 1 ) . GetCell ( 12 ) . SetCellValue ( "检测单位" ) ;
//尾部行2
ws . GetRow ( rowIndex + 2 ) . GetCell ( 0 ) . SetCellValue ( "" ) ;
ws . GetRow ( rowIndex + 2 ) . GetCell ( 3 ) . SetCellValue ( "" ) ;
ws . GetRow ( rowIndex + 2 ) . GetCell ( 6 ) . SetCellValue ( "" ) ;
ws . GetRow ( rowIndex + 2 ) . GetCell ( 8 ) . SetCellValue ( "" ) ;
ws . GetRow ( rowIndex + 2 ) . GetCell ( 12 ) . SetCellValue ( "" ) ;
//尾部行3
ws . GetRow ( rowIndex + 3 ) . GetCell ( 0 ) . SetCellValue ( "质量检测员:" ) ;
ws . GetRow ( rowIndex + 3 ) . GetCell ( 3 ) . SetCellValue ( "专业工程师:" ) ;
ws . GetRow ( rowIndex + 3 ) . GetCell ( 6 ) . SetCellValue ( "专业/质量工程师:" ) ;
ws . GetRow ( rowIndex + 3 ) . GetCell ( 8 ) . SetCellValue ( "业主代表:" ) ;
ws . GetRow ( rowIndex + 3 ) . GetCell ( 12 ) . SetCellValue ( "接收人:" ) ;
//尾部行6
ws . GetRow ( rowIndex + 6 ) . GetCell ( 0 ) . SetCellValue ( "专业工程师:" ) ;
//尾部行8
ws . GetRow ( rowIndex + 8 ) . GetCell ( 0 ) . SetCellValue ( " 年 月 日" ) ;
ws . GetRow ( rowIndex + 8 ) . GetCell ( 3 ) . SetCellValue ( " 年 月 日" ) ;
ws . GetRow ( rowIndex + 8 ) . GetCell ( 6 ) . SetCellValue ( " 年 月 日" ) ;
ws . GetRow ( rowIndex + 8 ) . GetCell ( 8 ) . SetCellValue ( " 年 月 日" ) ;
ws . GetRow ( rowIndex + 8 ) . GetCell ( 12 ) . SetCellValue ( " 年 月 日" ) ;
#endregion
ws = WsExcelCreateRow ( ws , hssfworkbook , rowIndex + 10 , rowIndex + 10 , style , 0 , 13 , 3 , true ) ;
rowIndex + = 11 ;
}
}
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 ) ;
}
FileInfo filet = new FileInfo ( ReportFileName ) ;
Response . Clear ( ) ;
Response . Charset = "GB2312" ;
Response . ContentEncoding = System . Text . Encoding . UTF8 ;
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
Response . AddHeader ( "Content-Disposition" , "attachment; filename=" + Server . UrlEncode ( "无损检测委托单(PMI).xlsx" ) ) ;
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
Response . AddHeader ( "Content-Length" , filet . Length . ToString ( ) ) ;
// 指定返回的是一个不能被客户端读取的流,必须被下载
Response . ContentType = "application/ms-excel" ;
// 把文件流发送到客户端
Response . WriteFile ( filet . FullName ) ;
// 停止页面的执行
Response . End ( ) ;
2024-06-20 17:12:59 +08:00
}
2024-06-21 16:37:50 +08:00
#region 私 有 方 法
2024-06-20 17:12:59 +08:00
/// <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>
2024-06-21 16:37:50 +08:00
/// 行和列
2024-06-20 17:12:59 +08:00
/// </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 )
{
2024-06-21 16:37:50 +08:00
ws . GetRow ( i ) . GetCell ( j ) . CellStyle = CommonPrint . SetExcelStyle ( hssfworkbook , BorderStyle . None , BorderStyle . None , BorderStyle . None , BorderStyle . None , VerticalAlignment . Center , HorizontalAlignment . Center , 10 , true , false ) ;
2024-06-20 17:12:59 +08:00
}
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
2024-05-11 15:22:08 +08:00
}
}