use of org.docx4j.wml.TblBorders in project Java-Tutorial by gpcodervn.
the class TableBordersTest method testTableBorderAbsenceExplicit.
@Test
public void testTableBorderAbsenceExplicit() throws Docx4JException {
Tbl tbl = table("<table border='0'><tr><td>1</td></tr></table>");
TblBorders borders = tbl.getTblPr().getTblBorders();
assertEquals(STBorder.NONE, borders.getTop().getVal());
assertEquals(STBorder.NONE, borders.getBottom().getVal());
assertEquals(STBorder.NONE, borders.getLeft().getVal());
assertEquals(STBorder.NONE, borders.getRight().getVal());
assertEquals(STBorder.NONE, borders.getInsideH().getVal());
assertEquals(STBorder.NONE, borders.getInsideV().getVal());
TcPrInner.TcBorders borders2 = ((Tc) ((Tr) tbl.getContent().get(0)).getContent().get(0)).getTcPr().getTcBorders();
assertNull(borders2.getTop());
assertNull(borders2.getBottom());
assertNull(borders2.getLeft());
assertNull(borders2.getRight());
assertNull(borders2.getInsideH());
assertNull(borders2.getInsideV());
}
use of org.docx4j.wml.TblBorders in project Java-Tutorial by gpcodervn.
the class TableBordersTest method testTableBorderAbsence.
@Test
public void testTableBorderAbsence() throws Docx4JException {
Tbl tbl = table("<table><tr><td>1</td></tr></table>");
TblBorders borders = tbl.getTblPr().getTblBorders();
assertEquals(STBorder.NONE, borders.getTop().getVal());
assertEquals(STBorder.NONE, borders.getBottom().getVal());
assertEquals(STBorder.NONE, borders.getLeft().getVal());
assertEquals(STBorder.NONE, borders.getRight().getVal());
assertEquals(STBorder.NONE, borders.getInsideH().getVal());
assertEquals(STBorder.NONE, borders.getInsideV().getVal());
TcPrInner.TcBorders borders2 = ((Tc) ((Tr) tbl.getContent().get(0)).getContent().get(0)).getTcPr().getTcBorders();
assertNull(borders2.getTop());
assertNull(borders2.getBottom());
assertNull(borders2.getLeft());
assertNull(borders2.getRight());
assertNull(borders2.getInsideH());
assertNull(borders2.getInsideV());
}
use of org.docx4j.wml.TblBorders in project docx4j-template by vindell.
the class Docx4J_简单例子 method addBorders.
// 表格增加边框
public void addBorders(Tbl table, String borderSize) {
table.setTblPr(new TblPr());
CTBorder border = new CTBorder();
border.setColor("auto");
border.setSz(new BigInteger(borderSize));
border.setSpace(new BigInteger("0"));
border.setVal(STBorder.SINGLE);
TblBorders borders = new TblBorders();
borders.setBottom(border);
borders.setLeft(border);
borders.setRight(border);
borders.setTop(border);
borders.setInsideH(border);
borders.setInsideV(border);
table.getTblPr().setTblBorders(borders);
}
use of org.docx4j.wml.TblBorders in project docx4j-template by vindell.
the class Docx4J_简单例子2 method addBorders.
// 表格增加边框
public void addBorders(Tbl table, String borderSize) {
table.setTblPr(new TblPr());
CTBorder border = new CTBorder();
border.setColor("auto");
border.setSz(new BigInteger(borderSize));
border.setSpace(new BigInteger("0"));
border.setVal(STBorder.SINGLE);
TblBorders borders = new TblBorders();
borders.setBottom(border);
borders.setLeft(border);
borders.setRight(border);
borders.setTop(border);
borders.setInsideH(border);
borders.setInsideV(border);
table.getTblPr().setTblBorders(borders);
}
use of org.docx4j.wml.TblBorders in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method setTblBorders.
/**
* @Description:表格增加边框 可以设置上下左右四个边框样式以及横竖水平线样式
*/
public void setTblBorders(TblPr tblPr, CTBorder topBorder, CTBorder rightBorder, CTBorder bottomBorder, CTBorder leftBorder, CTBorder hBorder, CTBorder vBorder) {
TblBorders borders = tblPr.getTblBorders();
if (borders == null) {
borders = new TblBorders();
tblPr.setTblBorders(borders);
}
if (topBorder != null) {
borders.setTop(topBorder);
}
if (rightBorder != null) {
borders.setRight(rightBorder);
}
if (bottomBorder != null) {
borders.setBottom(bottomBorder);
}
if (leftBorder != null) {
borders.setLeft(leftBorder);
}
if (hBorder != null) {
borders.setInsideH(hBorder);
}
if (vBorder != null) {
borders.setInsideV(vBorder);
}
}
Aggregations