直接上代码吧,NPOI的word处理中没有直接绘制对角线的方法,下面的代码可以做出对角线效果
public void TableDrawDiagonalLine(XWPFTable table, int row = 0, int col = 0) { CT_TblBorders tblBorders = new CT_TblBorders(); tblBorders.AddNewTop().val = ST_Border.none; tblBorders.AddNewLeft().val = ST_Border.none; tblBorders.AddNewBottom().val = ST_Border.none; tblBorders.AddNewRight().val = ST_Border.none; tblBorders.AddNewInsideH().val = ST_Border.none; tblBorders.AddNewInsideV().val = ST_Border.none; table.GetCTTbl().tblPr.tblBorders = tblBorders; var cell = table.GetRow(row).GetCell(col); CT_TcPr tcpr = cell.GetCTTc().AddNewTcPr(); CT_Border border1 = new CT_Border(); border1.val = ST_Border.single; border1.sz = 10; border1.color = "000000"; // Black color border1.space = (ulong)4; // Space between lines border1.shadow = ST_OnOff.True; tcpr.tcBorders = new CT_TcBorders(); tcpr.tcBorders.tl2br = border1; }
标签:word,val,C#,NPOI,ST,tblBorders,border1,Border,CT From: https://www.cnblogs.com/along007/p/18108977