Search in sources :

Example 21 with CTTblPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr in project poi by apache.

the class XWPFTable method setStyleID.

/**
     * Set the table style. If the style is not defined in the document, MS Word
     * will set the table style to "Normal".
     *
     * @param styleName - the style name to apply to this table
     */
public void setStyleID(String styleName) {
    CTTblPr tblPr = getTrPr();
    CTString styleStr = tblPr.getTblStyle();
    if (styleStr == null) {
        styleStr = tblPr.addNewTblStyle();
    }
    styleStr.setVal(styleName);
}
Also used : CTString(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString) CTTblPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr)

Example 22 with CTTblPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr in project poi by apache.

the class XWPFTable method setInsideVBorder.

public void setInsideVBorder(XWPFBorderType type, int size, int space, String rgbColor) {
    CTTblPr tblPr = getTrPr();
    CTTblBorders ctb = tblPr.isSetTblBorders() ? tblPr.getTblBorders() : tblPr.addNewTblBorders();
    CTBorder b = ctb.isSetInsideV() ? ctb.getInsideV() : ctb.addNewInsideV();
    b.setVal(xwpfBorderTypeMap.get(type));
    b.setSz(BigInteger.valueOf(size));
    b.setSpace(BigInteger.valueOf(space));
    b.setColor(rgbColor);
}
Also used : CTTblBorders(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblBorders) CTBorder(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder) CTTblPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr)

Example 23 with CTTblPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr in project poi by apache.

the class XWPFTable method getInsideHBorderType.

public XWPFBorderType getInsideHBorderType() {
    XWPFBorderType bt = null;
    CTTblPr tblPr = getTrPr();
    if (tblPr.isSetTblBorders()) {
        CTTblBorders ctb = tblPr.getTblBorders();
        if (ctb.isSetInsideH()) {
            CTBorder border = ctb.getInsideH();
            bt = stBorderTypeMap.get(border.getVal().intValue());
        }
    }
    return bt;
}
Also used : CTTblBorders(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblBorders) CTBorder(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder) CTTblPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr)

Example 24 with CTTblPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr in project poi by apache.

the class XWPFTable method setCellMargins.

public void setCellMargins(int top, int left, int bottom, int right) {
    CTTblPr tblPr = getTrPr();
    CTTblCellMar tcm = tblPr.isSetTblCellMar() ? tblPr.getTblCellMar() : tblPr.addNewTblCellMar();
    CTTblWidth tw = tcm.isSetLeft() ? tcm.getLeft() : tcm.addNewLeft();
    tw.setType(STTblWidth.DXA);
    tw.setW(BigInteger.valueOf(left));
    tw = tcm.isSetTop() ? tcm.getTop() : tcm.addNewTop();
    tw.setType(STTblWidth.DXA);
    tw.setW(BigInteger.valueOf(top));
    tw = tcm.isSetBottom() ? tcm.getBottom() : tcm.addNewBottom();
    tw.setType(STTblWidth.DXA);
    tw.setW(BigInteger.valueOf(bottom));
    tw = tcm.isSetRight() ? tcm.getRight() : tcm.addNewRight();
    tw.setType(STTblWidth.DXA);
    tw.setW(BigInteger.valueOf(right));
}
Also used : CTTblWidth(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth) CTTblPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr) CTTblCellMar(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblCellMar)

Example 25 with CTTblPr

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr in project poi by apache.

the class XWPFTable method getCellMarginTop.

public int getCellMarginTop() {
    int margin = 0;
    CTTblPr tblPr = getTrPr();
    CTTblCellMar tcm = tblPr.getTblCellMar();
    if (tcm != null) {
        CTTblWidth tw = tcm.getTop();
        if (tw != null) {
            margin = tw.getW().intValue();
        }
    }
    return margin;
}
Also used : CTTblWidth(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth) CTTblPr(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr) CTTblCellMar(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblCellMar)

Aggregations

CTTblPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr)26 CTTblBorders (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblBorders)11 CTBorder (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder)10 CTTblWidth (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth)7 CTString (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString)6 CTTblCellMar (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblCellMar)5 CTDecimalNumber (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber)4 BigInteger (java.math.BigInteger)3 XWPFParagraph (org.apache.poi.xwpf.usermodel.XWPFParagraph)3 XWPFTable (org.apache.poi.xwpf.usermodel.XWPFTable)3 XWPFTableCell (org.apache.poi.xwpf.usermodel.XWPFTableCell)3 XWPFTableRow (org.apache.poi.xwpf.usermodel.XWPFTableRow)3 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 XWPFDocument (org.apache.poi.xwpf.usermodel.XWPFDocument)2 XWPFRun (org.apache.poi.xwpf.usermodel.XWPFRun)2 CTHeight (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHeight)2 CTShd (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTShd)2 CTTbl (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl)2 CTTcPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr)2