use of org.docx4j.wml.TblBorders in project Java-Tutorial by gpcodervn.
the class TableBordersTest method testTableBorderStyles.
@Test
public void testTableBorderStyles() throws Docx4JException {
HashMap<String, STBorder> styles = new HashMap<String, STBorder>();
styles.put("none", STBorder.NONE);
styles.put("hidden", STBorder.NONE);
styles.put("solid", STBorder.SINGLE);
styles.put("dotted", STBorder.DOTTED);
styles.put("dashed", STBorder.DASHED);
styles.put("double", STBorder.DOUBLE);
styles.put("inset", STBorder.INSET);
styles.put("outset", STBorder.OUTSET);
// no direct substitution
styles.put("groove", STBorder.SINGLE);
// no direct substitution
styles.put("ridge", STBorder.SINGLE);
styles.put("anyOther", STBorder.NONE);
for (String style : styles.keySet()) {
Tbl tbl = table("<table style='border: 1px " + style + " black;'><tr><td>1</td></tr></table>");
TblBorders borders = tbl.getTblPr().getTblBorders();
assertEquals(styles.get(style), borders.getTop().getVal());
}
}
use of org.docx4j.wml.TblBorders in project Java-Tutorial by gpcodervn.
the class TableBordersTest method testTableBorderColors.
@Test
public void testTableBorderColors() throws Docx4JException {
Tbl tbl = table("<table style='border-style: solid; border-color:#111 #222 #333 #444;'><tr><th>1</th></tr></table>");
TblBorders borders = tbl.getTblPr().getTblBorders();
assertEquals("111111", borders.getTop().getColor());
assertEquals("222222", borders.getRight().getColor());
assertEquals("333333", borders.getBottom().getColor());
assertEquals("444444", borders.getLeft().getColor());
}
use of org.docx4j.wml.TblBorders in project Java-Tutorial by gpcodervn.
the class TableBordersTest method testTableBorderWidths.
@Test
public void testTableBorderWidths() throws Docx4JException {
Tbl tbl = table("<table style='border-style: solid; border-width: 0px 1px 2px 3px;'><tr><th>1</th></tr></table>");
TblBorders borders = tbl.getTblPr().getTblBorders();
assertNull(borders.getTop().getSz());
assertTrue(borders.getRight().getSz().longValue() > 0);
assertTrue(borders.getBottom().getSz().longValue() > borders.getRight().getSz().longValue());
assertTrue(borders.getLeft().getSz().longValue() > borders.getBottom().getSz().longValue());
}
use of org.docx4j.wml.TblBorders in project docx4j-template by vindell.
the class Docx4J_例子2 method addBorders.
// 表格增加边框 可以设置上下左右四个边框样式以及横竖水平线样式
public void addBorders(Tbl table, CTBorder topBorder, CTBorder bottomBorder, CTBorder leftBorder, CTBorder rightBorder, CTBorder hBorder, CTBorder vBorder) {
table.setTblPr(new TblPr());
TblBorders borders = new TblBorders();
borders.setBottom(bottomBorder);
borders.setLeft(leftBorder);
borders.setRight(rightBorder);
borders.setTop(bottomBorder);
borders.setInsideH(hBorder);
borders.setInsideV(vBorder);
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);
}
Aggregations