Search in sources :

Example 6 with TblBorders

use of org.docx4j.wml.TblBorders in project docx4j-template by vindell.

the class SettingColumnWidthForTable method addBorders.

/**
 *  本方法为表格添加边框
 */
private static void addBorders(Tbl table) {
    table.setTblPr(new TblPr());
    CTBorder border = new CTBorder();
    border.setColor("auto");
    border.setSz(new BigInteger("4"));
    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);
}
Also used : CTBorder(org.docx4j.wml.CTBorder) BigInteger(java.math.BigInteger) TblBorders(org.docx4j.wml.TblBorders) TblPr(org.docx4j.wml.TblPr)

Example 7 with TblBorders

use of org.docx4j.wml.TblBorders in project docx4j-template by vindell.

the class TableWithMergedCells method addBorders.

/**
 *  本方法为表格添加边框
 */
private static void addBorders(Tbl table) {
    table.setTblPr(new TblPr());
    CTBorder border = new CTBorder();
    border.setColor("auto");
    border.setSz(new BigInteger("4"));
    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);
}
Also used : CTBorder(org.docx4j.wml.CTBorder) BigInteger(java.math.BigInteger) TblBorders(org.docx4j.wml.TblBorders) TblPr(org.docx4j.wml.TblPr)

Example 8 with TblBorders

use of org.docx4j.wml.TblBorders in project docx4j-template by vindell.

the class TableWithStyledContent method addBorders.

/**
 *  本方法给表格添加边框
 */
private static void addBorders(Tbl table) {
    table.setTblPr(new TblPr());
    CTBorder border = new CTBorder();
    border.setColor("auto");
    border.setSz(new BigInteger("4"));
    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);
}
Also used : CTBorder(org.docx4j.wml.CTBorder) BigInteger(java.math.BigInteger) TblBorders(org.docx4j.wml.TblBorders) TblPr(org.docx4j.wml.TblPr)

Example 9 with TblBorders

use of org.docx4j.wml.TblBorders in project docx4j-template by vindell.

the class AddingAnInlineImageToTable method addBorders.

/**
 * 给表格添加简单的黑色边框.
 * @param table
 */
private static void addBorders(Tbl table) {
    table.setTblPr(new TblPr());
    CTBorder border = BorderUtils.ctBorder();
    TblBorders borders = BorderUtils.tblBorders(border);
    table.getTblPr().setTblBorders(borders);
}
Also used : CTBorder(org.docx4j.wml.CTBorder) TblBorders(org.docx4j.wml.TblBorders) TblPr(org.docx4j.wml.TblPr)

Example 10 with TblBorders

use of org.docx4j.wml.TblBorders in project Java-Tutorial by gpcodervn.

the class TableBordersTest method testTableBorderPresence.

@Test
public void testTableBorderPresence() throws Docx4JException {
    Tbl tbl = table("<table border='1'><tr><th>1</th></tr></table>");
    TblBorders borders = tbl.getTblPr().getTblBorders();
    assertEquals(STBorder.INSET, borders.getTop().getVal());
    assertEquals(STBorder.INSET, borders.getBottom().getVal());
    assertEquals(STBorder.INSET, borders.getLeft().getVal());
    assertEquals(STBorder.INSET, borders.getRight().getVal());
    assertEquals(STBorder.NONE, borders.getInsideH().getVal());
    assertEquals(STBorder.NONE, borders.getInsideV().getVal());
    assertTrue(borders.getTop().getSz().longValue() > 0);
    assertTrue(borders.getBottom().getSz().longValue() > 0);
    assertTrue(borders.getLeft().getSz().longValue() > 0);
    assertTrue(borders.getRight().getSz().longValue() > 0);
    TcPrInner.TcBorders borders2 = ((Tc) ((Tr) tbl.getContent().get(0)).getContent().get(0)).getTcPr().getTcBorders();
    assertEquals(STBorder.OUTSET, borders2.getTop().getVal());
    assertEquals(STBorder.OUTSET, borders2.getBottom().getVal());
    assertEquals(STBorder.OUTSET, borders2.getLeft().getVal());
    assertEquals(STBorder.OUTSET, borders2.getRight().getVal());
    assertNull(borders2.getInsideH());
    assertNull(borders2.getInsideV());
    assertTrue(borders2.getTop().getSz().longValue() > 0);
    assertTrue(borders2.getBottom().getSz().longValue() > 0);
    assertTrue(borders2.getLeft().getSz().longValue() > 0);
    assertTrue(borders2.getRight().getSz().longValue() > 0);
}
Also used : TcPrInner(org.docx4j.wml.TcPrInner) TblBorders(org.docx4j.wml.TblBorders) Tbl(org.docx4j.wml.Tbl) Test(org.junit.Test)

Aggregations

TblBorders (org.docx4j.wml.TblBorders)18 TblPr (org.docx4j.wml.TblPr)10 CTBorder (org.docx4j.wml.CTBorder)9 BigInteger (java.math.BigInteger)8 Tbl (org.docx4j.wml.Tbl)6 Test (org.junit.Test)6 TcPrInner (org.docx4j.wml.TcPrInner)3 HashMap (java.util.HashMap)1 STBorder (org.docx4j.wml.STBorder)1