Search in sources :

Example 21 with CTBorder

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

the class XSSFCellStyle method setLeftBorderColor.

/**
     * Set the color to use for the left border as a {@link XSSFColor} value
     *
     * @param color the color to use
     */
public void setLeftBorderColor(XSSFColor color) {
    CTBorder ct = getCTBorder();
    if (color == null && !ct.isSetLeft())
        return;
    CTBorderPr pr = ct.isSetLeft() ? ct.getLeft() : ct.addNewLeft();
    if (color != null)
        pr.setColor(color.getCTColor());
    else
        pr.unsetColor();
    int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme, _stylesSource.getIndexedColors()));
    _cellXf.setBorderId(idx);
    _cellXf.setApplyBorder(true);
}
Also used : CTBorder(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder) CTBorderPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr) XSSFCellBorder(org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder)

Example 22 with CTBorder

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

the class XSSFCellStyle method setBorderBottom.

/**
     * Set the type of border to use for the bottom border of the cell
     *
     * @param border - type of border to use
     * @see org.apache.poi.ss.usermodel.BorderStyle
     * @since POI 3.15
     */
@Override
public void setBorderBottom(BorderStyle border) {
    CTBorder ct = getCTBorder();
    CTBorderPr pr = ct.isSetBottom() ? ct.getBottom() : ct.addNewBottom();
    if (border == BorderStyle.NONE)
        ct.unsetBottom();
    else
        pr.setStyle(STBorderStyle.Enum.forInt(border.getCode() + 1));
    int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme, _stylesSource.getIndexedColors()));
    _cellXf.setBorderId(idx);
    _cellXf.setApplyBorder(true);
}
Also used : CTBorder(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder) CTBorderPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr) XSSFCellBorder(org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder)

Example 23 with CTBorder

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

the class XSSFCellStyle method getBorderRightEnum.

/**
     * Get the type of border to use for the right border of the cell
     * Will be removed when {@link #getBorderRight()} returns a BorderStyle enum
     *
     * @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE}
     * @since POI 3.15
     */
@Override
public BorderStyle getBorderRightEnum() {
    if (!_cellXf.getApplyBorder())
        return BorderStyle.NONE;
    int idx = (int) _cellXf.getBorderId();
    CTBorder ct = _stylesSource.getBorderAt(idx).getCTBorder();
    STBorderStyle.Enum ptrn = ct.isSetRight() ? ct.getRight().getStyle() : null;
    if (ptrn == null) {
        return BorderStyle.NONE;
    }
    return BorderStyle.valueOf((short) (ptrn.intValue() - 1));
}
Also used : CTBorder(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder) STBorderStyle(org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle)

Example 24 with CTBorder

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

the class XSSFCellStyle method setBottomBorderColor.

/**
     * Set the color to use for the bottom border
     *
     * @param color the color to use, null means no color
     */
public void setBottomBorderColor(XSSFColor color) {
    CTBorder ct = getCTBorder();
    if (color == null && !ct.isSetBottom())
        return;
    CTBorderPr pr = ct.isSetBottom() ? ct.getBottom() : ct.addNewBottom();
    if (color != null)
        pr.setColor(color.getCTColor());
    else
        pr.unsetColor();
    int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme, _stylesSource.getIndexedColors()));
    _cellXf.setBorderId(idx);
    _cellXf.setApplyBorder(true);
}
Also used : CTBorder(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder) CTBorderPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr) XSSFCellBorder(org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder)

Example 25 with CTBorder

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

the class XSSFCellStyle method setBorderLeft.

/**
     * Set the type of border to use for the left border of the cell
      *
     * @param border the type of border to use
     * @since POI 3.15
     */
@Override
public void setBorderLeft(BorderStyle border) {
    CTBorder ct = getCTBorder();
    CTBorderPr pr = ct.isSetLeft() ? ct.getLeft() : ct.addNewLeft();
    if (border == BorderStyle.NONE)
        ct.unsetLeft();
    else
        pr.setStyle(STBorderStyle.Enum.forInt(border.getCode() + 1));
    int idx = _stylesSource.putBorder(new XSSFCellBorder(ct, _theme, _stylesSource.getIndexedColors()));
    _cellXf.setBorderId(idx);
    _cellXf.setApplyBorder(true);
}
Also used : CTBorder(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder) CTBorderPr(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr) XSSFCellBorder(org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder)

Aggregations

CTBorder (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder)25 CTBorder (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder)11 Test (org.junit.Test)10 CTTblBorders (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblBorders)10 CTTblPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr)10 XSSFCellBorder (org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder)9 CTBorderPr (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr)9 STBorderStyle (org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle)4 CTString (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString)2 POIXMLException (org.apache.poi.POIXMLException)1 XmlException (org.apache.xmlbeans.XmlException)1 CTFill (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill)1 CTFont (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont)1 CTStylesheet (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet)1 CTP (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP)1 CTPBdr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPBdr)1 CTPPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr)1